示例#1
0
        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 void button1_Click(object sender, EventArgs e)
        {
            Uri          ur    = new Uri("http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM");
            YouTubeQuery query = new YouTubeQuery("http://gdata.youtube.com/feeds/api/channels?q=vevo");



            YouTubeFeed  videoFeed = service.Query(query);
            YouTubeEntry en        = (YouTubeEntry)videoFeed.Entries[0];

            Video          video    = request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId));
            Feed <Comment> comments = request.GetComments(video);
            string         cm       = "";

            foreach (Comment c in comments.Entries)
            {
                cm += c.Content + "\n------------------------------------------\n";
            }

            VideoInfo info = new VideoInfo();

            info.Get("yUHNUjEs7rQ");
            //Video v = request.Retrieve<Video>(videoEntryUrl);



            //Feed<Comment> comments = request.GetComments(v);

            //string cm = "";
            //foreach (Comment c in comments.Entries)
            //{
            //  cm += c.Author + c.Content + "------------------------------------------";
            //}
        }
        public override void Search(object term)
        {
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            //query.VQ = searchString;
            query.Query   = term.ToString();
            query.OrderBy = "relevance";
            query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND));

            YouTubeFeed vidr = Youtube2MP.service.Query(query);

            SearchResult.Items.Clear();
            foreach (YouTubeEntry entry in vidr.Entries)
            {
                SearchResultItem item = new SearchResultItem();
                item.Id       = entry.VideoId;
                item.Label    = entry.Title.Text;
                item.Provider = this;
                item.MetaData.Add("entry", entry);
                SearchResult.Items.Add(item);
            }
            IsBusy = false;
            if (SearchDone != null)
            {
                SearchDone(this);
            }
        }
示例#4
0
        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);
        }
示例#5
0
 protected void LoadRelatated(YouTubeEntry entry)
 {
     try
     {
         //Youtube2MP.getIDSimple(Youtube2MP.NowPlayingEntry.Id.AbsoluteUri));
         //GUIControl.ClearControl(GetID, listControl.GetID);
         string relatatedUrl = string.Format("http://gdata.youtube.com/feeds/api/videos/{0}/related",
                                             Youtube2MP.GetVideoId(entry));
         relatated.Clear();
         YouTubeQuery query = new YouTubeQuery(relatatedUrl);
         YouTubeFeed  vidr  = Youtube2MP.service.Query(query);
         // time to time this query return nothing, maybe the quata limit ..
         if (vidr.Entries.Count == 0)
         {
             vidr = Youtube2MP.service.Query(query);
         }
         if (vidr.Entries.Count > 0)
         {
             addVideos(vidr, query);
         }
         if (listControl != null)
         {
             FillRelatedList();
         }
     }
     catch (Exception exception)
     {
         Log.Debug("[YouTube.Fm]Error {0}\n{1}", exception.Message, exception.StackTrace);
     }
 }
示例#6
0
        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);
        }
示例#7
0
        public void YouTubeQueryPrivateTest()
        {
            Tracing.TraceMsg("Entering YouTubeQueryPrivateTest");

            YouTubeQuery   query   = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
            YouTubeService service = new YouTubeService("NETUnittests", 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)
                {
                    counter++;
                }
            }
            Assert.IsTrue(counter == 0, "counter was " + counter);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.FolderType = 1;
            string user = entry.GetValue("user");

            user = string.IsNullOrEmpty(user) ? "default" : user;
            YouTubeQuery query =
                new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/favorites", user));

            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 = videos.Title.Text;
            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            res.Add(Youtube2MP.GetPager(entry, videos));
            res.ItemType = ItemType.Video;
            return(res);
        }
示例#9
0
        public void YouTubeFeedConstructorTest()
        {
            Uri         uriBase  = null; // TODO: Initialize to an appropriate value
            IService    iService = null; // TODO: Initialize to an appropriate value
            YouTubeFeed target   = new YouTubeFeed(uriBase, iService);

            Assert.IsNotNull(target);
        }
示例#10
0
        public void CreateFeedEntryTest()
        {
            Uri          uriBase  = null;                               // TODO: Initialize to an appropriate value
            IService     iService = null;                               // TODO: Initialize to an appropriate value
            YouTubeFeed  target   = new YouTubeFeed(uriBase, iService); // TODO: Initialize to an appropriate value
            YouTubeEntry entry    = target.CreateFeedEntry() as YouTubeEntry;

            Assert.IsNotNull(entry);
        }
        private void DoListSelection()
        {
            GUIListItem selectedItem = listControl.SelectedListItem;

            if (selectedItem != null)
            {
                if (selectedItem.Label != "..")
                {
                    YouTubeQuery qu = selectedItem.MusicTag as YouTubeQuery;
                    if (qu != null)
                    {
                        YouTubeFeed vidr = service.Query(qu);
                        Log.Debug("Next page: {0}", qu.Uri.ToString());
                        if (vidr.Entries.Count > 0)
                        {
                            SaveListState(true);
                            addVideos(vidr, false, qu);
                            UpdateGui();
                        }
                    }
                    //--------------------
                    LocalFileStruct file = selectedItem.MusicTag as LocalFileStruct;
                    YouTubeEntry    vide;
                    if (file != null)
                    {
                        Uri   videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId);
                        Video video         = Youtube2MP.request.Retrieve <Video>(videoEntryUrl);
                        vide = video.YouTubeEntry;
                    }
                    else
                    {
                        vide = selectedItem.MusicTag as YouTubeEntry;
                    }

                    if (vide != null)
                    {
                        if (vide.VideoId == null)
                        {
                            ShowVevo(vide.Authors[0].Name);
                        }
                        else
                        {
                            DoPlay(vide, true, listControl.ListView);
                        }
                    }
                }
                else
                {
                    DoBack();
                }
            }
            GUIWaitCursor.Hide();
            //throw new Exception("The method or operation is not implemented.");
        }
示例#12
0
        private void button1_Click(object sender, EventArgs e)
        {
            Uri ur =
                new Uri(
                    "http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM");
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            //order results by the number of views (most viewed first)
            query.OrderBy = "viewCount";

            //exclude restricted content from the search
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
            //string ss = YouTubeQuery.TopRatedVideo;
            //http://gdata.youtube.com/feeds/api/standardfeeds/top_rated
            //search for puppies!
            query.Query = textBox1.Text;
            query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND));

            YouTubeFeed  videoFeed = service.Query(query);
            YouTubeEntry en        = (YouTubeEntry)videoFeed.Entries[0];
            string       s         = en.Summary.Text;
            string       s1        = en.Media.Description.Value;

            Google.GData.YouTube.MediaGroup gr = en.Media;

            Uri            videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId);
            Video          video         = request.Retrieve <Video>(videoEntryUrl);
            Feed <Comment> comments      = request.GetComments(video);
            string         cm            = "";

            foreach (Comment c in comments.Entries)
            {
                cm += c.Content + "\n------------------------------------------\n";
            }

            VideoInfo info = new VideoInfo();

            info.Get("yUHNUjEs7rQ");
            //Video v = request.Retrieve<Video>(videoEntryUrl);



            //Feed<Comment> comments = request.GetComments(v);

            //string cm = "";
            //foreach (Comment c in comments.Entries)
            //{
            //  cm += c.Author + c.Content + "------------------------------------------";
            //}
        }
        private void ShowVevo(string user)
        {
            YouTubeQuery query;

            if (!string.IsNullOrEmpty(user))
            {
                if (user.ToLower() == "vevo")
                {
                    query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/vevo/favorites"));
                }
                else
                {
                    query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", user));
                }
            }
            else
            {
                query = new YouTubeQuery("http://gdata.youtube.com/feeds/api/channels?q=vevo");
            }


            //if (queryuri == YouTubeQuery.CreateFavoritesUri(null))
            //    query = SetParamToYouTubeQuery(query, true);
            //else
            //{
            //    query = SetParamToYouTubeQuery(query, false);
            //}

            query.NumberToRetrieve = 50;
            query.SafeSearch       = YouTubeQuery.SafeSearchValues.None;
            if (uploadtime != YouTubeQuery.UploadTime.AllTime)
            {
                query.Time = uploadtime;
            }

            YouTubeFeed vidr = service.Query(query);

            if (vidr.Entries.Count > 0)
            {
                SaveListState(true);
                addVideos(vidr, false, query);
                GUIPropertyManager.SetProperty("#header.title", vidr.Title.Text);
                UpdateGui();
            }
            else
            {
                Err_message("No item was found !");
            }
        }
示例#14
0
 YouTubeEntry GetVideFromFeed(string videoId, YouTubeFeed videos)
 {
     if (videos == null)
     {
         return(null);
     }
     foreach (YouTubeEntry youTubeEntry in videos.Entries)
     {
         if (Youtube2MP.GetVideoId(youTubeEntry) == videoId)
         {
             return(youTubeEntry);
         }
     }
     return(null);
 }
        private void SearchVideo(string searchString)
        {
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            query = SetParamToYouTubeQuery(query, false);
            //query.VQ = searchString;
            query.Query   = searchString;
            query.OrderBy = "relevance";

            YouTubeFeed vidr = service.Query(query);

            foreach (AtomLink link in vidr.Links)
            {
                if (link.Rel == "http://schemas.google.com/g/2006#spellcorrection")
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
                    if (null == dlgYesNo)
                    {
                        return;
                    }
                    dlgYesNo.SetHeading("Did you mean ?"); //resume movie?
                    dlgYesNo.SetLine(1, link.Title);
                    dlgYesNo.SetDefaultToYes(true);
                    dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                    if (dlgYesNo.IsConfirmed)
                    {
                        SearchVideo(link.Title);
                        return;
                    }
                }
            }

            if (vidr.Entries.Count > 0)
            {
                SaveListState(true);
                addVideos(vidr, false, query);
                UpdateGui();
                if (_setting.SearchHistory.Contains(searchString.Trim()))
                {
                    _setting.SearchHistory.Remove(searchString.Trim());
                }
                _setting.SearchHistory.Add(searchString.Trim());
            }
            else
            {
                Err_message("No item was found !");
            }
        }
 public static GenericListItem GetPager(SiteItemEntry entry, YouTubeFeed videos)
 {
     if (videos.TotalResults > videos.StartIndex + ITEM_IN_LIST)
     {
         SiteItemEntry newEntry = entry.Copy();
         newEntry.StartItem += ITEM_IN_LIST;
         GenericListItem listItem = new GenericListItem()
         {
             Title        = Translation.NextPage,
             IsFolder     = true,
             DefaultImage = "NextPage.png",
             Tag          = newEntry
         };
         return(listItem);
     }
     return(null);
 }
示例#17
0
        private void LoadRelatated()
        {
            if (Youtube2MP.NowPlayingEntry.RelatedVideosUri != null)
            {
                GUIControl.ClearControl(GetID, listControl.GetID);
                relatated.Clear();

                Video        video = Youtube2MP.request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + Youtube2MP.NowPlayingEntry.VideoId));
                YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", video.Author));

                YouTubeFeed vidr = Youtube2MP.service.Query(query);
                if (vidr.Entries.Count > 0)
                {
                    addVideos(vidr, query);
                }
            }
        }
示例#18
0
        public void YouTubeReadOnlyTest()
        {
            Tracing.TraceMsg("Entering YouTubeReadOnlyTest");

            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");
            }
        }
示例#19
0
        private static void parseFeed(YouTubeFeed feed, List <Item> videos)
        {
            string description = "";
            string url         = null;

            foreach (YouTubeEntry entry in feed.Entries)
            {
                description = "";
                url         = String.Format(youtubeWatchUrlTemplate, entry.VideoId);
                if (entry.Media.Description != null)
                {
                    description = entry.Media.Description.Value;
                }
                YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, description);
                videos.Add(video);
            }
        }
        /// <summary>
        /// returns the video this activity was related to
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public Video GetVideoForActivity(Activity activity)
        {
            Video rv = null;

            if (activity.ActivityEntry != null)
            {
                AtomUri      address = activity.ActivityEntry.VideoLink;
                YouTubeQuery q       = PrepareQuery <YouTubeQuery>(address.ToString());
                YouTubeFeed  f       = this.Service.Query(q);

                if (f != null && f.Entries.Count > 0)
                {
                    rv           = new Video();
                    rv.AtomEntry = f.Entries[0];
                }
            }

            return(rv);
        }
示例#21
0
        protected void addVideos(YouTubeFeed videos, YouTubeQuery qu)
        {
            downloaQueue.Clear();
            foreach (YouTubeEntry entry in videos.Entries)
            {
                GUIListItem item = new GUIListItem();
                // and add station name & bitrate
                item.Label    = entry.Title.Text; //ae.Entry.Author.Name + " - " + ae.Entry.Title.Content;
                item.Label2   = "";
                item.IsFolder = false;

                try
                {
                    item.Duration = Convert.ToInt32(entry.Duration.Seconds, 10);
                    if (entry.Rating != null)
                    {
                        item.Rating = (float)entry.Rating.Average;
                    }
                }
                catch
                {
                }

                string imageFile = Youtube2MP.GetLocalImageFileName(GetBestUrl(entry.Media.Thumbnails));
                if (File.Exists(imageFile))
                {
                    item.ThumbnailImage = imageFile;
                    item.IconImage      = imageFile;
                    item.IconImageBig   = imageFile;
                }
                else
                {
                    MediaPortal.Util.Utils.SetDefaultIcons(item);
                    item.OnRetrieveArt += item_OnRetrieveArt;
                    DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
                    //DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
                }
                item.MusicTag = entry;
                relatated.Add(item);
            }
            //OnDownloadTimedEvent(null, null);
        }
        private void InitList(string queryuri)
        {
            if (_setting.MusicFilter && queryuri != YouTubeQuery.CreateFavoritesUri(null))
            {
                queryuri += "_Music";
            }
            string reg = GetRegionOpt();

            if (!string.IsNullOrEmpty(reg))
            {
                queryuri = queryuri.Replace("standardfeeds", "standardfeeds/" + reg);
            }
            YouTubeQuery query = new YouTubeQuery(queryuri);

            //if (queryuri == YouTubeQuery.CreateFavoritesUri(null))
            //    query = SetParamToYouTubeQuery(query, true);
            //else
            //{
            //    query = SetParamToYouTubeQuery(query, false);
            //}

            query.NumberToRetrieve = 50;
            query.SafeSearch       = YouTubeQuery.SafeSearchValues.None;
            if (uploadtime != YouTubeQuery.UploadTime.AllTime)
            {
                query.Time = uploadtime;
            }

            YouTubeFeed vidr = service.Query(query);

            if (vidr.Entries.Count > 0)
            {
                SaveListState(true);
                addVideos(vidr, false, query);
                GUIPropertyManager.SetProperty("#header.title", vidr.Title.Text);
                UpdateGui();
            }
            else
            {
                Err_message("No item was found !");
            }
        }
示例#23
0
 protected void deletePlaylist(string playlistUrl)
 {
     if (CheckUsernameAndPassword())
     {
         Login();
         YouTubeQuery query = new YouTubeQuery()
         {
             Uri = new Uri(YouTubeQuery.CreatePlaylistsUri(accountname)), StartIndex = 1, NumberToRetrieve = 50
         };                                                                                                                                              // max. 50 per query
         YouTubeFeed feed = service.Query(query);
         foreach (PlaylistsEntry e in feed.Entries)
         {
             if (e.Content.Src.Content.Substring(e.Content.Src.Content.IndexOf("://")) == playlistUrl.Substring(playlistUrl.IndexOf("://")))
             {
                 e.Delete();
                 break;
             }
         }
     }
 }
示例#24
0
        private static void update(string queryTemplate, List <Item> videos, ref int counter, string category)
        {
            if (videos.Count != 0 || (counter % 20 != 0 && counter != 0))
            {
                counter = counter + 1;
                return;
            }

            counter = counter + 1;

            videos.Clear();
            int maxResults = 50;
            int startIndex = 1;

            string feedUrl = String.Format(queryTemplate, startIndex, maxResults);

            YouTubeQuery query     = new YouTubeQuery(feedUrl);
            YouTubeFeed  videoFeed = null;

            try
            {
                videoFeed = service.Query(query);
                while (videoFeed.Entries.Count > 0)
                {
                    parseFeed(videoFeed, videos);

                    startIndex += maxResults;
                    feedUrl     = String.Format(queryTemplate, startIndex, maxResults);
                    query       = new YouTubeQuery(feedUrl);
                    videoFeed   = service.Query(query);
                }
                startIndex = 1;
                Log <Youtube> .Debug("Finished updating {0} videos", category);
            }
            catch (Exception e)
            {
                Log <Youtube> .Error("Error getting {0} videos - {1}", category, e.Message);

                Log <Youtube> .Debug(e.StackTrace);
            }
        }
示例#25
0
        /////////////////////////////////////////////////////////////////////////////



        [Test] public void YouTubeUploaderTest()
        {
            YouTubeQuery query = new YouTubeQuery();

            query.Uri = new Uri(CreateUri(this.resourcePath + "uploaderyt.xml"));

            YouTubeService service = new YouTubeService("NETUnittests", 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");
        }
示例#26
0
        public void YouTubeFeedTest()
        {
            Tracing.TraceMsg("Entering YouTubeFeedTest");

            YouTubeQuery   query   = new YouTubeQuery(YouTubeQuery.TopRatedVideo);
            YouTubeService service = new YouTubeService("NETUnittests", 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");
            }
        }
示例#27
0
        void addVideos(YouTubeFeed videos, YouTubeQuery qu)
        {
            foreach (YouTubeEntry entry in videos.Entries)
            {
                GUIListItem item = new GUIListItem();
                // and add station name & bitrate
                item.Label    = entry.Title.Text; //ae.Entry.Author.Name + " - " + ae.Entry.Title.Content;
                item.Label2   = "";
                item.IsFolder = false;

                try
                {
                    item.Duration = Convert.ToInt32(entry.Duration.Seconds, 10);
                    item.Rating   = (float)entry.Rating.Average;
                }
                catch
                {
                }

                string imageFile = GetLocalImageFileName(GetBestUrl(entry.Media.Thumbnails));
                if (File.Exists(imageFile))
                {
                    item.ThumbnailImage = imageFile;
                    item.IconImage      = "defaultVideoBig.png";
                    item.IconImageBig   = imageFile;
                }
                else
                {
                    MediaPortal.Util.Utils.SetDefaultIcons(item);
                    item.OnRetrieveArt += new GUIListItem.RetrieveCoverArtHandler(item_OnRetrieveArt);
                    DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
                    //DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
                }
                item.MusicTag = entry;
                listControl.Add(item);
                relatated.Add(item);
            }
            updateStationLogoTimer.Enabled = true;;
        }
示例#28
0
        public List <YoutubeVideo> SearchVideo(string query, int numberToRetrieve, string orderBy)
        {
            YouTubeService service      = new YouTubeService(_applicationName, _developerKey);
            const String   searchFields = "entry(id,title,link[@rel='alternate'],author(name,yt:userId),media:group(media:category(@label),media:credit,yt:videoid,yt:uploaderId),yt:statistics,yt:rating,gd:rating(@average),gd:comments/gd:feedLink(@countHint))";
            String         url          = String.Format("{0}?v=2&fields={1}", _videoUrl, searchFields);

            YouTubeQuery searchQuery = new YouTubeQuery(url);

            searchQuery.Query            = query;
            searchQuery.NumberToRetrieve = numberToRetrieve;
            searchQuery.OrderBy          = orderBy;

            YouTubeFeed searchResults = service.Query(searchQuery);

            List <YoutubeVideo> videos = new List <YoutubeVideo>();

            foreach (YouTubeEntry entry in searchResults.Entries)
            {
                videos.Add(entry.ToYoutubeVideo());
            }

            return(videos);
        }
示例#29
0
 private static void GetPlaylistEntriesAsCategories(Category parentCategory, YouTubeFeed feed)
 {
     foreach (PlaylistsEntry entry in feed.Entries)
     {
         RssLink playlistLink = new RssLink();
         playlistLink.Name = entry.Title.Text;
         playlistLink.EstimatedVideoCount = (uint)entry.CountHint;
         XmlExtension playlistExt = entry.FindExtension(YouTubeNameTable.PlaylistId, YouTubeNameTable.NSYouTube) as XmlExtension;
         if (playlistExt != null)
         {
             playlistLink.Url = string.Format(PLAYLIST_FEED, playlistExt.Node.InnerText);
             parentCategory.SubCategories.Add(playlistLink);
             playlistLink.ParentCategory = parentCategory;
         }
     }
     // if there are more results add a new NextPageCategory
     if (feed.NextChunk != null)
     {
         parentCategory.SubCategories.Add(new NextPageCategory()
         {
             ParentCategory = parentCategory, Url = feed.NextChunk
         });
     }
 }
示例#30
0
        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");
        }