0

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?

Ashwin Singh
  • 7,197
  • 4
  • 36
  • 55
  • 1
    If the API does not support what you require, then there simply isn't a way to accomplish your goal using the API. A solution (although perhaps undesirable) could be to use a web server to download these feeds and echo the video IDs to the page. This would allow you to greatly decrease the amount of unnecessary data that the client would be downloading, shifting the majority of the load to a web server (which presumably is well equipped with a strong enough connection to not have to worry about such data reduction). – Spooky Jun 11 '12 at 00:06
  • Yeah, I think this would be the only option, thanks! – Ashwin Singh Jun 11 '12 at 05:16

1 Answers1

0

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

Ashwin Singh
  • 7,197
  • 4
  • 36
  • 55