private IList<Webinar> LoadWebinars() { var service = new YouTubeService("HibernatingRhinosExercise"); var query = new FeedQuery(_uri); var webinars = new List<Webinar>(); AtomFeed result = service.Query(query); if (result != null) { webinars = ParseAtomFeed(result); } return webinars; }
public IList<Webinar> FindWebinars(string keyword) { var service = new YouTubeService("HibernatingRhinosExercise"); var query = new FeedQuery("https://gdata.youtube.com/feeds/api/videos?q={0}" + keyword); var webinars = new List<Webinar>(); AtomFeed result = service.Query(query); if (result != null) { webinars = ParseAtomFeed(result); } return webinars; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube factory object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeGetActivitiesTest() { ActivitiesQuery query = new ActivitiesQuery(); query.ModifiedSince = new DateTime(1980, 12, 1); YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey); if (this.userName != null) { service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd); } ActivitiesFeed feed = service.Query(query) as ActivitiesFeed; foreach (ActivityEntry e in feed.Entries ) { Assert.IsTrue(e.VideoId != null, "There should be a videoid"); } service = null; }
///////////////////////////////////////////////////////////////////////////// [Test] public void YouTubeUploaderTest() { YouTubeQuery query = new YouTubeQuery(); query.Uri = new Uri(CreateUri(this.resourcePath + "uploaderyt.xml")); YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey); if (this.userName != null) { service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd); } YouTubeFeed feed = service.Query(query); YouTubeEntry entry = feed.Entries[0] as YouTubeEntry; YouTube.MediaCredit uploader = entry.Uploader; Assert.IsTrue(uploader != null); Assert.IsTrue(uploader.Role == "uploader"); Assert.IsTrue(uploader.Scheme == "urn:youtube"); Assert.IsTrue(uploader.Value == "GoogleDevelopers"); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube Feed object using the read only service</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeReadOnlyTest() { Tracing.TraceMsg("Entering YouTubeFeedTest"); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.TopRatedVideo); YouTubeService service = new YouTubeService("NETUnittests"); query.Formats.Add(YouTubeQuery.VideoFormat.RTSP); query.Time = YouTubeQuery.UploadTime.ThisWeek; YouTubeFeed feed = service.Query(query); foreach (YouTubeEntry e in feed.Entries ) { Assert.IsTrue(e.Media.Title.Value != null, "There should be a title"); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube Feed object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeFeedTest() { Tracing.TraceMsg("Entering YouTubeFeedTest"); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.TopRatedVideo); YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey); if (this.userName != null) { service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd); } query.Formats.Add(YouTubeQuery.VideoFormat.RTSP); query.Time = YouTubeQuery.UploadTime.ThisWeek; YouTubeFeed feed = service.Query(query); foreach (YouTubeEntry e in feed.Entries ) { Assert.IsTrue(e.Media.Title.Value != null, "There should be a title"); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube feed, trying to find private videos</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeQueryPrivateTest() { Tracing.TraceMsg("Entering YouTubeQueryPrivateTest"); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey); query.Query = "Education expertvillage"; query.NumberToRetrieve = 50; if (this.userName != null) { service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd); } YouTubeFeed feed = service.Query(query); int counter = 0; foreach (YouTubeEntry e in feed.Entries ) { Assert.IsTrue(e.Media.Title.Value != null, "There should be a title"); if (e.Private == true) { counter++; } } Assert.IsTrue(counter == 0, "counter was " + counter); }
public void YouTubeUploaderTest() { Tracing.TraceMsg("Entering YouTubeUploaderTest"); YouTubeQuery query = new YouTubeQuery(); query.Uri = new Uri(CreateUri(Path.Combine(this.resourcePath, "uploaderyt.xml"))); YouTubeService service = new YouTubeService("NETUnittests", this.ytDevKey); if (!string.IsNullOrEmpty(this.ytUser)) { service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd); } YouTubeFeed feed = service.Query(query); YouTubeEntry entry = feed.Entries[0] as YouTubeEntry; YouTube.MediaCredit uploader = entry.Uploader; Assert.IsTrue(uploader != null); Assert.IsTrue(uploader.Role == "uploader"); Assert.IsTrue(uploader.Scheme == "urn:youtube"); Assert.IsTrue(uploader.Value == "GoogleDevelopers"); }
// This is function that load video title and url public void tb_KeyDown(Object sender, KeyEventArgs e) { TextBox tmp = (TextBox)sender; if(e.KeyCode == Keys.Enter){ if (tmp.Text == strTmp) { strTmp = ""; player.DocumentText = ""; return; } strTmp = tmp.Text; YouTubeService service = new YouTubeService("MusicTube"); YouTubeQuery query = new YouTubeQuery(); query.StartIndex = 0; query.NumberToRetrieve = 10; query.Uri = new Uri(String.Format("http://gdata.youtube.com/feeds/api/videos?vq={0}", HttpUtility.UrlEncode(tmp.Text)) ); YouTubeFeed feed = service.Query(query); int i = 0; lbx.Items.Clear(); foreach (YouTubeEntry entry in feed.Entries) { MediaGroup group = entry.Media; //タイトルと説明 //Console.WriteLine("Title / {0}", group.Title.Value); //コンテンツ数分ループ foreach (MediaContent content in group.Contents) { SortedList attributes = content.Attributes; //属性数分ループ foreach (DictionaryEntry attribute in attributes) { //Console.WriteLine("Thumbnail key / {0}", attribute.Value + "\n"); if (attribute.Key.Equals("url")) { //サムネイルのURL //Console.WriteLine("Thumbnail key / {0}", attribute.Value + "\n"); strData = (string)attribute.Value; //Console.WriteLine("test:{0}\n", strData.IndexOf("?")); //Console.WriteLine("aaa:\n" + strData); if (strData.IndexOf("?") < 0) { i--; break; } lbx.Items.Add(group.Title.Value); strData = strData.Substring(0, strData.IndexOf("?")); strUrl[i] = strData; //Console.WriteLine("test2:{0}\n", strData); break; } } break; } if (i >= 9) break; i++; } } }
private static IEnumerable<Video> LoadVideos(string url) { var youTubeService = new YouTubeService(Factory.GoogleApplicationName); var query = new YouTubeQuery(url); var feed = youTubeService.Query(query); var videos = new List<Video>(); foreach (YouTubeEntry entry in feed.Entries) { var video = Factory.CreateVideo(entry); videos.Add(video); } return videos; }
private YouTubeFeed GetUserVideos(ID id) { YouTubeFeed ytFeed = null; ID parentID = id; if (parentID != (ID)null) { string authorName = GetAuthorName(parentID); if (!string.IsNullOrEmpty(authorName)) { try { YouTubeService ytService = new YouTubeService("Sitecore YouTube Data Provider", GoogleDevKey); // Retrieve only video entries from YouTube service. YouTubeQuery ytQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); ytQuery.Author = authorName; // Set this property to Strict or Moderate to make sure that restricted feeds do not make it into result feed. // Results could also be restricted by setting up Restriction property to an IP address. Only allowed feeds will be retrieved for that IP address. // By default this property is set to caller's IP address. ytQuery.SafeSearch = YouTubeQuery.SafeSearchValues.Strict; ytQuery.NumberToRetrieve = MaxResultsCount; ytFeed = ytService.Query(ytQuery); } catch (Exception ex) { Log.Error(ex.Message, this); } } } return ytFeed; }