private void button3_Click(object sender, EventArgs e) { label5.Text = "Search Results:"; try { string searchupd = "http://nicoding.com/api.php?app=ripleech&updtrend=search&term=" + textBox2.Text; HttpWebRequest searchreq = (HttpWebRequest)WebRequest.Create(searchupd); WebResponse searchres = searchreq.GetResponse(); System.IO.StreamReader sr = new System.IO.StreamReader(searchres.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1252")); string pluginsavail = sr.ReadToEnd(); } catch { } listView1.Items.Clear(); YouTubeRequest request = new YouTubeRequest(settings); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //order results by the number of views (most viewed first) query.OrderBy = "relevance"; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = textBox2.Text; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed <Video> videoFeed = request.Get <Video>(query); printVideoFeed(videoFeed); }
public static string getSearchVal(string searchvar) { searchtext = searchvar; YouTubeRequestSettings yy = new YouTubeRequestSettings("unitysg", "AIzaSyAS1TLHGyfD6yP596kpmckOhUepSPmo8hM"); YouTubeRequest request = new YouTubeRequest(yy); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri + "?region=SG&v=2"); //order results by the number of views (most viewed first) // query.OrderBy = "viewCount"; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = searchvar; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed <Video> videoFeed = request.Get <Video>(query); if (printVideoFeed(videoFeed) == true) { return("Success"); } else { return("Fail"); } }
public GenericListItemCollections GetList(SiteItemEntry entry) { GenericListItemCollections res = new GenericListItemCollections(); res.Title = entry.Title; YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", entry.GetValue("id"))); if (string.IsNullOrEmpty(entry.GetValue("id"))) { query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/default/uploads")); } query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST; query.StartIndex = entry.StartItem; if (entry.StartItem > 1) { res.Paged = true; } YouTubeFeed videos = Youtube2MP.service.Query(query); res.Title = "Uploads by :" + videos.Authors[0].Name; foreach (YouTubeEntry youTubeEntry in videos.Entries) { res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry)); } res.Add(Youtube2MP.GetPager(entry, videos)); res.ItemType = ItemType.Video; return(res); }
public static List <Video> RandomSearch() { try { List <Video> vids = new List <Video>(); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); query.OrderBy = "viewCount"; query.Query = "Smartest machine on earth documentary"; int cat = rd.Next(0, 1); string feu = "https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today"; if (cat == 1) { feu += "&duration=long"; } Feed <Video> videofeed = yourequest.Get <Video>(new System.Uri(feu + "&genre=" + cat.ToString())); foreach (Video entry in videofeed.Entries) { vids.Add(entry); } return(vids); } catch { return(null); } }
public static Video GetBestVideo(int cat, string lang) { try { YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); query.OrderBy = "viewCount"; query.Query = "Smartest machine on earth"; string feu = "https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today&hl=" + lang; Feed <Video> videofeed = yourequest.Get <Video>(new System.Uri(feu + "&genre=" + cat.ToString())); Video vid = null; int max = 0; foreach (Video entry in videofeed.Entries) { if (entry.ViewCount > max) { max = entry.ViewCount; vid = entry; } } return(vid); } catch { return(null); } }
protected YouTubeQuery SetParamToYouTubeQuery(YouTubeQuery query, bool safe) { //order results by the number of views (most viewed first) query.OrderBy = "viewCount"; query.StartIndex = 1; //query.LR = "hu"; if (_setting.UseExtremFilter) { query.NumberToRetrieve = 50; } else { query.NumberToRetrieve = 50; } ////exclude restricted content from the search //query.Racy = "exclude"; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; if (uploadtime != YouTubeQuery.UploadTime.AllTime) { query.Time = uploadtime; } if (_setting.MusicFilter && !safe) { query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND)); } return(query); }
public GenericListItemCollections GetList(SiteItemEntry entry) { GenericListItemCollections res = new GenericListItemCollections(); res.FolderType = 1; string url = string.Format("http://gdata.youtube.com/feeds/api/playlists/{0}", entry.GetValue("id")); if (!string.IsNullOrEmpty(entry.GetValue("url"))) { url = entry.GetValue("url"); } YouTubeQuery query = new YouTubeQuery(url); query.NumberToRetrieve = 50; do { YouTubeFeed videos = Youtube2MP.service.Query(query); res.Title = videos.Title.Text; foreach (YouTubeEntry youTubeEntry in videos.Entries) { res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry)); } query.StartIndex += 50; if (videos.TotalResults < query.StartIndex + 50) { break; } } while (true); res.ItemType = ItemType.Video; return(res); }
private IEnumerable <Google.YouTube.Video> GetVideos(string videofeed) { // YouTubeQuery.CreatePlaylistsUri() var query = new YouTubeQuery(videofeed); return(GetVideos(query)); }
private void AddVideoFeed(YouTubeQuery q) { try { YouTubeRequest request = GetRequest(); Feed <Video> feed = request.Get <Video>(q); feed.Maximum = 500;//11_5_13 ss: limited to 500 now?? if (!Object.Equals(feed, null) && !Object.Equals(feed.Entries, null)) { foreach (Video vid in feed.Entries) { _channel.Feed.Add(new ChannelVideo(vid)); } } } catch (GDataRequestException gdre) { using (var logClient = new BILoggerServiceClient()) logClient.HandleException(gdre.Message, "Query: " + q.Query, Utility.ApplicationName, LogTypeEnum.Error, LogActionEnum.LogAndEmail, "ChannelManager.GetVideos()", "Drone.API.YouTube Exception", string.Empty, string.Empty, System.Environment.MachineName); } catch (Exception e) { using (var logClient = new BILoggerServiceClient()) logClient.HandleBIException(e.ConvertToBIException(LogActionEnum.Log, LogTypeEnum.Error, "Drone.API.YouTube Exception", "ChannelManager.GetVideos()", "nouser", System.Environment.MachineName, "Query: " + q.Query)); } }
public static bool GetSongsByArtist(string artist, ref List <Song> songs, ref YouTubeFeed vidr) { Log.Debug("Youtube GetSongsByArtist for : {0}", artist); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //query.VQ = artist; query.Query = artist; //order results by the number of views (most viewed first) query.OrderBy = "relevance"; //exclude restricted content from the search query.NumberToRetrieve = 20; //query.Racy = "exclude"; query.SafeSearch = YouTubeQuery.SafeSearchValues.Strict; query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND)); vidr = service.Query(query); foreach (YouTubeEntry entry in vidr.Entries) { if (entry.Title.Text.ToUpper().Contains(artist.ToUpper().Trim()) && entry.Title.Text.Contains("-")) { songs.Add(YoutubeEntry2Song(entry)); } } return(true); }