I have 10 youtube channels that I like and I want to get the latest video information for each channel. Right now i'm doing 10 different calls like this one:
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2&alt=jsonc&start-index=1&max-results=1
I want to replace those 10 calls with a single one by using a batch request.
I tryed this:
String xml = "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch'>" +
" <batch:operation type='query'/>" +
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_1</id>" +
" </entry>" +
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_2</id>" +
" </entry>" +
...
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_10</id>" +
" </entry>" +
"</feed>";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https://gdata.youtube.com/feeds/api/videos/batch?v=2");
StringEntity se = new StringEntity(xml);
se.setContentType("text/xml");
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
I'm getting a XML with usefull data in the HTTPResponse object.
But if I want to get the 10 latest videos information, I won't know the videoId.
Does anybody know how to achieve this ?
You can retrieve entire playlists, users' uploads, and even search results using the YouTube API. You can also add YouTube functionalities to your website so that users can upload videos and manage channel subscriptions straight from your website or app.
Standard feeds are updated periodically, with the update frequency varying from feed to feed. Many feeds are updated every 30 to 40 minutes but other feeds such as those that capture daily, weekly or monthly results – may only be updated hourly or even daily. Check the link above for more information.
The snippet object contains basic details about the video, such as its title, description, and category. The date and time that the video was published.
You can't make a batch request that includes 10 different http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2
URLs in the request body.
You would need to request http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2&max-results=1
10 times, once with each USERNAME
.
Alternatively, if you have some sort server-side process that's interested in finding out when new videos are uploaded to a given channel, you can use either PubSubHubbub or SUP to handle that scenario more efficiently. Because your question was tagged with android
I'm assuming that you care about doing this client-side, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With