user264953
user264953

Reputation: 1967

How to retrieve youtube thumbnails using Google API Client Library for Java

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

Upvotes: 5

Views: 3415

Answers (1)

Brian
Brian

Reputation: 16206

Using the example URL from the reference page:

URL: http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2&alt=jsonc

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"
}

You can modify the sample classes to parse the thumbnail object.

Upvotes: 4

Related Questions