我有一堆youtube VideoID(youtube网址的param watch/v =?中的字母数字字符串),我必须获取每个视频的缩略图;
I have a bunch of youtube VideoIDs (the alfanumeric string in the param watch/v=? of the youtube 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:
gdata.youtube/feeds/api/videos/VIDEOID?v = 2& alt = json (s/VIDEOID/actualVideoID/)
gdata.youtube/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)...
谢谢 朱波
推荐答案显然,"q"参数可用于多个视频ID.例如:
Apparently the "q" parameter can work for multiple video id's. For example:
gdata.youtube/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:获取缩略图
发布评论