Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube Channel Banner Image URL

Hi have been working on this project for quite some time, and It has come to the point at which I need to get the channel banner of a user's channel. I have this url (https://i2.ytimg.com/i/zRJMLe36PT0Q2mhlmbU2OQ/1.jpg) that gets the channel avatar of the channel avatar via the channel id. (the id is the long string of text and numbers) I searched the internet for quite some time also, and was at no luck to finding the url. If anyone can find a url that works the same as the avatar, just for the channel banner, I would be greatly appreciated! Thanks, and cheers! (ps, I would rather not use php, but if there is a solution using php, I can use it)

like image 644
CthruME Avatar asked May 28 '14 18:05

CthruME


People also ask

What are YouTube banner links?

But YouTube has added an area where you can overlay up to five active links on top of the banner image. They appear in the bottom right corner. You can use those spots for traditional links to websites. Your homepage would be a natural example.

Can YouTube banner be PNG?

YouTube banner format and file sizeAccepted file formats for YouTube banners are JPG, PNG, BMP, and non-animated GIF. All YouTube banners must be up to 6MB file size.


2 Answers

You can get the banner image of a Youtube channel. Where the URL includes the word 'channel' followed by a 24 character string such as: https://www.youtube.com/channel/UCNa8NxMgSm7m4Ii9d4QGk1Q, then the following code will retrieve the banner information and more:

https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id={CHANNEL_ID}&key={GOOGLE_API_KEY}

Search for 'bannerImageUrl' to speed up the process if you are in a browser.

If you do not have a Google API key, visit the console and create one under the credentials menu. You should remove the curly brackets and not place the channel id or API key between them.

If you want to get the banner image of a YouTube channel with the word 'user' in the URL, such as: https://www.youtube.com/user/cocacola then I am not so sure. The solution on this page did not work for me.

I have just come across this result which shows more information.

like image 140
atw Avatar answered Sep 24 '22 05:09

atw


Using Java with Jsoup to get the channels header image without using Youtube API:

public final static String YOUTUBE_HEADER_IMAGE_START_URL = "yt3.ggpht.com/";
public final static String YOUTUBE_HEADER_IMAGE_END_URL = "-no-nd-rj";

private void getYoutubeChannelHeaderImage(String channelUrl) throws IOException
{
    Document document = Jsoup.connect(channelUrl).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1").get();
    
    String html = document.toString();
    Pattern pattern = Pattern.compile(YOUTUBE_HEADER_IMAGE_START_URL + "(.*?)" + YOUTUBE_HEADER_IMAGE_END_URL, Pattern.DOTALL);
    Matcher matcher = pattern.matcher(html); 
    while (matcher.find()) { 
        String imgUrl = matcher.group(1); 
        if (imgUrl.length()<500) 
            System.out.println("https://" + YOUTUBE_HEADER_IMAGE_START_URL+imgUrl+YOUTUBE_HEADER_IMAGE_END_URL); 
    }  
}

This code will output all available dimensions of a Youtube channel header image.

https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1138-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj // 1138 x 188
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1707-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj // 1707 x 282
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w2120-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj // 2120 x 350
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w2276-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj // 2276 x 376
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w2560-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj // 2560 x 423
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w320-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj // 320 x 180
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w854-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj // 854 x 480
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1280-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj // 1280 x 720
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1920-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj // 1920 x 1080
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w2120-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj // 2120 x 1192
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w320-fcrop64=1,32b75a57cd48a5a8-k-c0xffffffff-no-nd-rj // 320 x 52
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w640-fcrop64=1,32b75a57cd48a5a8-k-c0xffffffff-no-nd-rj // 640 x 105
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w960-fcrop64=1,32b75a57cd48a5a8-k-c0xffffffff-no-nd-rj // 960 x 158
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1280-fcrop64=1,32b75a57cd48a5a8-k-c0xffffffff-no-nd-rj // 1280 x 211
https://yt3.ggpht.com/2fCpG8MNmWvT8zz7MBFVlPMOA07bekDqK7FgNrdbh7ldLccLMsU1UwKlI1t3SJ5vxNJoA5pIYw=w1440-fcrop64=1,32b75a57cd48a5a8-k-c0xffffffff-no-nd-rj // 1440 x 238
like image 33
Student Avatar answered Sep 23 '22 05:09

Student