public List <VideoObject> Search_Video_Name(string keyword)
        {
            string link = $"https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=11&q={keyword}&type=video&key={api_token}";

            using (var wb = new WebClient())
            {
                var response             = wb.DownloadString(link);
                var tmpResult            = JObject.Parse(response);
                var temp_video_title     = tmpResult["items"].Values("snippet").Values("title").ToArray();
                var temp_video_id        = tmpResult["items"].Values("id").Values("videoId").ToArray();
                var temp_video_thumbnail = tmpResult["items"].Values("snippet").Values("thumbnails").Values("high").Values("url").ToArray();

                List <VideoObject> video_list = new List <VideoObject>();
                for (int i = 0; i < 10; i++)
                {
                    string      temp_video_url = string.Format("https://www.youtube.com/watch?v={0}", temp_video_id[i].ToString());
                    VideoObject video_obj      = new VideoObject(temp_video_title[i].ToString(), temp_video_url, temp_video_thumbnail[i].ToString());
                    video_list.Add(video_obj);
                }
                return(video_list);
            }
        }
Beispiel #2
0
 private void AddItem(VideoObject obj)
 {
     lb_items.Items.Add(obj.video_title);
 }