Youtube Gdata用户Feed停止工作

时间:2015-05-11 11:00:05

标签: c# youtube gdata

我有一个应用程序正在收集来自youtube用户的视频。 从3天开始停止播放并且没有关注视频,listview中唯一一个视频显示的是YouTube视频:“https://www.youtube.com/devicesupport

我已经阅读了该网址,但仍然不明白为什么它不起作用。如果有人有同样的问题,我将很乐意帮助我。 我的代码:

   private void Get_Video_Of_Searched_User()
    {
        using (new CWaitCursor())
        {
            int TotalVideoFound = 0;
            string VideoID = string.Empty;
            string YouTube_User = this.Txt_Youtube_UserName.Text;

            int StartIndex = (Current_Page * 50) + 1;

            YouTubeService ytsService = new YouTubeService(strAppName, strKey);
            Uri urlEntryUrl = default(Uri);
            urlEntryUrl = new Uri("https://gdata.youtube.com/feeds/api/users/" + YouTube_User + "/uploads?&max-results=50&start-index=" + StartIndex.ToString() + "");


            FeedQuery fqResults = new FeedQuery();
            fqResults.Uri = urlEntryUrl;
            Feed<Video> vidFeed = new Feed<Video>(ytsService, fqResults);

            try
            {
                TotalVideoFound = vidFeed.TotalResults;
            }
            catch
            {
                MessageBox.Show("Incorrect Username.");
                return;
            }

            if (StartIndex == 1)
                Lbl_TotalVideos.Text = "Total Videos: (" + TotalVideoFound.ToString() + ")";

            Enable_Disable_Next_And_Previous_Buttons(TotalVideoFound);
            SortedDictionary<string, string> ListViewItems = new SortedDictionary<string, string>();

            Dict_User_Links_With_Title.Clear();
            foreach (Video vidEntry in vidFeed.Entries)
            {
                if (ListViewItems.ContainsKey(vidEntry.Title) == true) continue;
                ListViewItems.Add(vidEntry.Title, vidEntry.ViewCount.ToString());
                VideoID = vidEntry.Id;
                if (!Dict_User_Links_With_Title.ContainsKey(VideoID.Substring(VideoID.LastIndexOf(":") + 1)))
                    Dict_User_Links_With_Title.Add(VideoID.Substring(VideoID.LastIndexOf(":") + 1), vidEntry.Title);
            }

            ListView_User_Video_Links.Items.Clear();

            string[] MyListItems = new string[2];
            foreach (KeyValuePair<string, string> entry in ListViewItems)
            {
                MyListItems[0] = entry.Key;
                MyListItems[1] = entry.Value;
                ListView_User_Video_Links.Items.Add(new ListViewItem(MyListItems));
            }

            string TotalViews = Get_Youtube_User_Total_Views(YouTube_User);
            this.Total_Views_For_User.Text = "Total Views: (" + TotalViews + ")";

        }
    }

1 个答案:

答案 0 :(得分:0)

YouTube Data API第3版具有Google API控制台中列出的具体配额号,您可在其中注册API密钥。您可以使用30,000单位/秒/用户和50,000,000每天。 如果您达到了限制,Google将停止返回结果,直到您的配额重置为止。