Youtube .NET Data API: Retrieve only videoID?

耗尽温柔 提交于 2019-12-11 18:09:39

问题


I am using youtube's .NET API to retrieve video feeds, here is the code:

        String[] ids;
        YouTubeRequestSettings settings = new YouTubeRequestSettings("My App Name", "My App Key");
        YouTubeRequest request = new YouTubeRequest(settings);
        Uri uri =
        new Uri("http://gdata.youtube.com/feeds/api/users/nptelhrd/uploads?max-results=50");//Change "GoogleDevelopers" to "default"
        Google.GData.Client.Feed<Video> videoFeed = request.Get<Video>(uri);
        ids = new String[videoFeed.TotalResults];

        int count = 0;
        for (int i = 0; i < 50; i++)
            ids[i] = videoFeed.Entries.ElementAt(i).VideoId;
        for (int i = 50; i < ids.Length-50; i+=50)
        {

            Uri uri2 =
   new Uri("http://gdata.youtube.com/feeds/api/users/nptelhrd/uploads?max-results=50&start-index=" + i.ToString());//Change "GoogleDevelopers" to "default"
            Google.GData.Client.Feed<Video> videoFeed2 = request.Get<Video>(uri);
            for (int j = 0; j < 50; j++)
            {
                ids[i+j] = videoFeed2.Entries.ElementAt(j).VideoId;
                count++;
            }
        }

The above code returns every information(Title, Description, ViewCount, Rating....etc.) for each video uploaded by the user "nptelhrd". There are 6950 videos uploaded by this particular user.

THE ABOVE CODE TAKES 15 MINUTES TO EXECUTE on a 512Kbps connection, because it retrieves all information of each and every video, its painfully slow, wastes a lot of server resources. Can't the above code be modified so that it only retrieve videoId's? How can I only retrieve videoId's of all videos?


回答1:


With the present limitations of .NET YOUTUBE API, its not possible to retrieve only VIDEOID.



来源:https://stackoverflow.com/questions/10968099/youtube-net-data-api-retrieve-only-videoid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!