thalsharif
thalsharif

Reputation: 357

How to get channel logo using youtube api?

I am using java in programming with youtube api library. as written in title I want to get source link for youtube channel logo (image in top left corner beside channel name). for example: http://www.youtube.com/user/NationalGeographic here it's my try:

YouTubeService service = new YouTubeService("NationalGeographic");
String feedUrl = http://gdata.youtube.com/feeds/api/users/NationalGeographic/uploads;   
VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);
String title = videoFeed.getTitle().getPlainText();

so I got channel name but I can't get channel logo. please any help.

Upvotes: 3

Views: 4887

Answers (2)

Ramon Medeiros
Ramon Medeiros

Reputation: 2631

With the new v3 API, you can get it by listing the channel:

https://developers.google.com/youtube/v3/docs/channels/list

They retrieve the logo in different sizes

Here is the output of Joe Rogan Experience :

{
 "kind": "youtube#channelListResponse",
 "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/_RZUfBijoiFpUwyyBzSuSJbKOi8\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/zhDVFVQYUTKigur2_WU6BMjm2Qo\"",
   "id": "UCzQUP1qoWDoEbmsQxvdjxgQ",
   "snippet": {
    "title": "PowerfulJRE",
    "description": "The Joe Rogan Experience podcast",
    "customUrl": "joerogan",
    "publishedAt": "2013-01-12T01:40:14.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/a/AGF-l78OfG5OxzCfyyoFqw-dKeiFNGzTIT4YgpMK4Q=s88-c-k-c0xffffffff-no-rj-mo",
      "width": 88,
      "height": 88
     },
     "medium": {
      "url": "https://yt3.ggpht.com/a/AGF-l78OfG5OxzCfyyoFqw-dKeiFNGzTIT4YgpMK4Q=s240-c-k-c0xffffffff-no-rj-mo",
      "width": 240,
      "height": 240
     },
     "high": {
      "url": "https://yt3.ggpht.com/a/AGF-l78OfG5OxzCfyyoFqw-dKeiFNGzTIT4YgpMK4Q=s800-c-k-c0xffffffff-no-rj-mo",
      "width": 800,
      "height": 800
     }
    },
    "localized": {
     "title": "PowerfulJRE",
     "description": "The Joe Rogan Experience podcast"
    }
   },
   "contentDetails": {
    "relatedPlaylists": {
     "uploads": "UUzQUP1qoWDoEbmsQxvdjxgQ",
     "watchHistory": "HL",
     "watchLater": "WL"
    }
   },
   "statistics": {
    "viewCount": "1783605586",
    "commentCount": "0",
    "subscriberCount": "7180000",
    "hiddenSubscriberCount": false,
    "videoCount": "2305"
   }
  }
 ]
}

Upvotes: 1

Adrian
Adrian

Reputation: 235

I don't think you can get it with the v2 API (although I hope you can), but the link structure for these images is somewhat similar:

http://i2.ytimg.com/i/UHW94eEFW7hkUMVaZz4eDg/1.jpg?v=d69778
http://i4.ytimg.com/i/7-BWdwziR8LozMCBD1Ei7w/1.jpg?v=d8170b

Wonder where those ids come from...

Upvotes: 0

Related Questions