GData Youtube : obtaining thumbnails

2019-07-20 05:13发布

问题:

I have a bunch of youtube VideoIDs (the alfanumeric string in the param watch/v=? of the youtube.com url) and I have to obtain the thumbnails for each video;

Now, for each videoid I make up an HTTP GET request like the following:

http://gdata.youtube.com/feeds/api/videos/VIDEOID?v=2&alt=json (s/VIDEOID/actualVideoID/)

And I parse/play around with the json returned; But this approach is quite expensive in terms of performance (everything would be running on a mobile device): is there a way to make a single HTTP connection (maybe POSTing the VideoIDs, instead of GETting them)...

Thanks Giupo

回答1:

Apparently the "q" parameter can work for multiple video id's. For example:

https://gdata.youtube.com/feeds/api/videos?q="7mSE-Iy_tFY"|"qybUFnY7Y8w"|"svC2XlPFW1g"&alt=json&fields=entry/id,entry/media:group/media:thumbnail

However note that the result can give extra videos because one of you're requested id's could be in another video's metadata. So you need to filter the results down to just those with the your original id list.

Alternatively it looks like you might be able to use a "batch request".