views:

364

answers:

2

Hello everybody, I am wondering if there is a way to query YouTube for multiple random videos (video id's are known) in a single query? I am storing video id's in the local db and need to show multiple details(list with thumbs, rating, author name,etc.) in the web page.

I am looking at the Youtube Data API and see that I can a single entity data like this:

Uri  videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/video_id");
Video video = request.Retrieve<Video>(videoEntryUrl);

Repeating this in the loop seems to be a bad idea, because of the quotas.

There is also "batch processing" available - http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html#Batch_processing. Seems like I can issue up to 50 random request, but it expects some feed I don't have as a parameter, when executing batch. There is an overload with some Uri, but it is not documented well - google-gdata.googlecode.com/svn/docs/folder59/M_Google_GData_Client_FeedRequest_1_Batch__1_2.htm

Does anybody have any ideas on how to retrieve multiple video entries by id's? Any help would be appreciated.

A: 

You can send multiple requests to youtube data api wrapped in a single request. YouTube allows you to send at most 50 multiple requests in a single request. This kind of request is known as a batch processing request. I have developed a working piece of code specifically for this problem. I had to do same kind of thing for a website I was working on. Anyways you can see how to do it from here (sample code is also present for download): http://www.ovaistariq.net/2010/06/youtube-batch-processing-requests-made-less-costly/

ovais.tariq
A: 

I too had exactly the same problem, I needed a list of video objects related to an arbitrary list of video id's, i.e. not conforming to any of the feeds.

The batch processing option is very tempting, but the implementation seems quite heavy for what should be pretty simple functionality.

At the end of the day, doing a basic video search for the id's separated by pipe "|" achieves the required result:

http://gdata.youtube.com/feeds/api/videos?q=h5jKcDH9s64|elzqvWXG1Y

Hope this helps

RobD