如何使用谷歌API客户端库Java获取YouTube的缩略图 [英] How to retrieve youtube thumbnails using Google API Client Library for Java
问题描述
我将不得不,如果你能请让我知道,通过它我可以使用谷歌API客户端库的Java,类似于我们使用GDATA获取缩略图的方式检索YouTube的缩略图的方式。
I would be obliged, if you could kindly let me know the means by which I can retrieve the youtube thumbnails using Google API Client Library for Java, similar to the way in which we fetched thumbnails using gdata.
List<String> thumbnails = new LinkedList<String>();
for (MediaThumbnail mediaThumbnail : mediaGroup.getThumbnails()) {
thumbnails.add(mediaThumbnail.getUrl());
}
展望未来, 问候, 罗尼
Looking forward, Regards, Rony
推荐答案
从使用示例URL的<一个href="http://$c$c.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media%3athumbnail">reference页面:
网址:<一href="http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2&alt=jsonc">http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2&alt=jsonc
我们可以提取的相关部分的JSON的一个例子:
we can extract an example of one of the relevant pieces of JSON:
"thumbnail": {
"sqDefault":"http://i.ytimg.com/vi/PpUgUrU5XUA/default.jpg",
"hqDefault":"http://i.ytimg.com/vi/PpUgUrU5XUA/hqdefault.jpg"
}
您可以修改<一个href="http://$c$c.google.com/p/google-api-java-client/source/browse/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/?repo=samples#youtube/model">sample班来解析缩略图对象。
You can modify the sample classes to parse the thumbnail object.
这篇关于如何使用谷歌API客户端库Java获取YouTube的缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!