Why can I get only 25 YouTube video from a feed?

2020-04-14 09:38发布

问题:

I have this code on C#/.NET :

string user = "Username";
string feedUrl = "http://gdata.youtube.com/feeds/api/users/" + user + "/uploads";
Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));

foreach (Video entry in videoFeed.Entries)
{
    // print video
}

but I can retrieve only 25 video!

I know the max number of video in a feed is 999 :

The API returns a videos feed in response to a request to search for videos. A videos feed contains a maximum of 999 entries. To retrieve search results, send an API request to the following URL:

http://gdata.youtube.com/feeds/projection/videos?v=2

So why 25?

Tried with uploads/?start-index=0&max-results=999 but nothing...

回答1:

The 999 figure refers to the maximum number of videos that can exist in a playlist or feed:

The API returns a videos feed in response to a request to search for videos. A videos feed contains a maximum of 999 entries.

By default it returns 25 results, though you can override this:

The max-results parameter specifies the maximum number of results that should be included in the result set. This parameter works in conjunction with the start-index parameter to determine which results to return. For example, to request the second set of 10 results – i.e. results 11-20 – set the max-results parameter to 10 and the start-index parameter to 11. The default value of this parameter is 25, and the maximum value is 50. However, for displaying lists of videos, we recommend that you set the max-results parameter to 10.

http://code.google.com/intl/it-IT/apis/youtube/2.0/reference.html#max-resultssp

The maximum value of max-results is 50, so you'll need to issue multiple requests using start-index to fetch each block of results.