GData Youtube:获取缩略图 [英] GData Youtube : obtaining thumbnails
问题描述
我有一堆youtube VideoID(youtube.com网址的param watch/v =?中的字母数字字符串),我必须获取每个视频的缩略图;
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;
现在,我为每个videoid组成一个HTTP GET请求,如下所示:
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/)
http://gdata.youtube.com/feeds/api/videos/VIDEOID?v=2&alt=json (s/VIDEOID/actualVideoID/)
然后我解析/播放返回的json;但是这种方法在性能方面非常昂贵(一切都将在移动设备上运行):有没有办法建立单个HTTP连接(也许是发布VideoID,而不是获取它们)...
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)...
谢谢 朱波
推荐答案
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
但是请注意,由于您要求的其中一个ID可能位于另一视频的元数据中,因此结果可以提供更多的视频.因此,您需要将结果过滤为仅包含原始ID列表的结果.
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".
这篇关于GData Youtube:获取缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!