Windows Forms: Youtube Search in C#

How to Create a Youtube Search using YoutubeSearch library in C#. YoutubeSearch is a library for .NET, written in C#, to show search query results from YouTube

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "YoutubeSearchDemo" and then click OK

youtube search in c#Step 2: Right click on your project select Manage NuGet Packages -> Search youtubesearch -> Install

youtube search installStep 3: Design youtube search form as below

youtube search in c#

Step 4: You need to create a Video class to map data

public class Video
    public string Title { get; set; }
    public string Author { get; set; }
    public string Url { get; set; }
    public Image Thumbnail { get; set; }

Add code to handle youtube search form

private void btnSearch_Click(object sender, EventArgs e)
    VideoSearch items = new VideoSearch();
    List<Video> list = new List<Video>();
    foreach (var item in items.SearchQuery(txtSearch.Text, 1))
        Video video = new Video();
        video.Title = item.Title;
        video.Author = item.Author;
        video.Url = item.Url;
        byte[] imageBytes = new WebClient().DownloadData(item.Thumbnail);
        //Get thubnail video
        using (MemoryStream ms = new MemoryStream(imageBytes))
            //Read image from stream
            video.Thumbnail = Image.FromStream(ms);
    //Add videos to datagridview
    videoBindingSource.DataSource = list;