fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.48k stars 793 forks source link

Thumbnail is missing in getInfo() - YouTube code updated #433

Closed barbhackk closed 5 years ago

barbhackk commented 5 years ago

Hi,

I think YouTube has updated its code ! Indeed since this morning I can not manage to recover the thumbnail of video.

I use the latest ytdl-core.

My package.json :

{
  "main": "index.js",
  "dependencies": {
    "ytdl-core": "0.29.2"
  }
}

When I try to get thumbnail with:

const ytdl = require('ytdl-core');
ytdl.getInfo("https://www.youtube.com/watch?v=FgeRDFai3C4", (err, info) => {
  console.log(info.thumbnail_url);
})

In console I have : "undefined"

See this demo : https://repl.it/repls/DentalLightyellowOop

Looking a little I saw that the thumbnail was in the node "player-response" (console.log(info.player-response))

But we can not access it.

Thanks for your help,

Barbhackk

BrunoMoreira99 commented 5 years ago

The available thumbnails are in info.player_response.videoDetails.thumbnail.thumbnails. It's what I personally have been using to get the video thumbnail. (The last element of the array will always have the thumbnail with "higher" resolution, which isn't actually the highest res YouTube has, it's still a very small image, but I'm afraid that's the best we can get.

I'm not sure if this URL always works or if it will keep working but... if you need the maximum resolution thumbnail you can try getting it from https://img.youtube.com/vi/${videoID}/maxresdefault.jpg, replacing ${videoID} with the id of the video, eg: https://img.youtube.com/vi/FgeRDFai3C4/maxresdefault.jpg or also https://i.ytimg.com/vi/FgeRDFai3C4/maxresdefault.jpg

Note: This might not work for all videos, as we've seen in issue #155. And some resolutions might include black bars.

barbhackk commented 5 years ago

The available thumbnails are in info.player_response.videoDetails.thumbnail.thumbnails. It's what I personally have been using to get the video thumbnail. (The last element of the array will always have the thumbnail with "higher" resolution, which isn't actually the highest res YouTube has, it's still a very small image, but I'm afraid that's the best we can get.

I'm not sure if this URL always works or if it will keep working but... if you need the maximum resolution thumbnail you can try getting it from https://img.youtube.com/vi/${videoID}/maxresdefault.jpg, replacing ${videoID} with the id of the video, eg: https://img.youtube.com/vi/FgeRDFai3C4/maxresdefault.jpg or also https://i.ytimg.com/vi/FgeRDFai3C4/maxresdefault.jpg

Note: This might not work for all videos, as we've seen in issue #155. And some resolutions might include black bars.

Thanks @BrunoMoreira99 it's works now.

nasir03082409229 commented 4 years ago

@BrunoMoreira99 Thanks a lot