CthruME
CthruME

Reputation: 143

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)

Upvotes: 9

Views: 47014

Answers (3)

stavros.3p
stavros.3p

Reputation: 2324

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

Upvotes: 6

Jay Long
Jay Long

Reputation: 39

i found a super quick way to do this. you can find the url in the console. i clicked on my avatar and then selected "my channel" from the nav. from there, click customize channel. now right click somewhere on the image. and then click inspect to open the console. you should now be targeting a div with an id of something like c4-header-bg-container. under the styles tab, there is a background-image attribute for that id. just copy the value inside the url() function. make sure you either remove the leading slashes or prepend https: to them. that is the url of your image. you may now do as thou wilt with it.

Upvotes: 0

atw
atw

Reputation: 5840

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.

Upvotes: 4

Related Questions