My info thumbnail is an Object, if so, then how would I get the URL? Because I wanna make an Embed with thumbnail,
let info = ytdl.getInfo(url);
let song = {
.
.
.
thumbnail: info.videoDetails.thumbnail
}
let embed = new Discord.MessageEmbed()
.setTitle('title')
.setThumbnail(*Place the url here*);
//But I can't because ytdl.videoDetails.thumbnail is an Object
I also tried ytdl.thumbnail_url but it always return undefined. How do I fix this?
Edit: I found out the solution, I made a function that resolves the info, and I did resolve.videoDetails.thumbnail.thumbnails[0], but my question is what's the difference between all the thumbnails array? Its output is like this:
2020-11-11T09:10:52.637829+00:00 app[Worker.1]: {
2020-11-11T09:10:52.637859+00:00 app[Worker.1]: url: 'https://i.ytimg.com/vi/60ItHLz5WEA/hqdefault.jpg?sqp=-oaymwEiCKgBEF5IWvKriqkDFQgBFQAAAAAYASUAAMhCPQCAokN4AQ==&rs=AOn4CLAzsxKizpa2mZYBrOH005QuoyAdFg',
2020-11-11T09:10:52.637859+00:00 app[Worker.1]: width: 168,
2020-11-11T09:10:52.637860+00:00 app[Worker.1]: height: 94
2020-11-11T09:10:52.637860+00:00 app[Worker.1]: }
2020-11-11T09:10:52.638123+00:00 app[Worker.1]: {
2020-11-11T09:10:52.638124+00:00 app[Worker.1]: url: 'https://i.ytimg.com/vi/60ItHLz5WEA/hqdefault.jpg?sqp=-oaymwEiCMQBEG5IWvKriqkDFQgBFQAAAAAYASUAAMhCPQCAokN4AQ==&rs=AOn4CLDQGF6CaUYDS1CTr7F-d4wHUwIbHQ',
2020-11-11T09:10:52.638124+00:00 app[Worker.1]: width: 196,
2020-11-11T09:10:52.638125+00:00 app[Worker.1]: height: 110
2020-11-11T09:10:52.638125+00:00 app[Worker.1]: }
2020-11-11T09:10:52.638351+00:00 app[Worker.1]: {
2020-11-11T09:10:52.638352+00:00 app[Worker.1]: url: 'https://i.ytimg.com/vi/60ItHLz5WEA/hqdefault.jpg?sqp=-oaymwEjCPYBEIoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLDAHBlU1s8kk2TDD-4QIPK5uWi82g',
2020-11-11T09:10:52.638353+00:00 app[Worker.1]: width: 246,
2020-11-11T09:10:52.638353+00:00 app[Worker.1]: height: 138
2020-11-11T09:10:52.638353+00:00 app[Worker.1]: }
2020-11-11T09:10:52.638512+00:00 app[Worker.1]: {
2020-11-11T09:10:52.638513+00:00 app[Worker.1]: url: 'https://i.ytimg.com/vi/60ItHLz5WEA/hqdefault.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLAHEApS5HDlKsdjg0HSscTqdFZwxg',
2020-11-11T09:10:52.638514+00:00 app[Worker.1]: width: 336,
2020-11-11T09:10:52.638514+00:00 app[Worker.1]: height: 188
2020-11-11T09:10:52.638514+00:00 app[Worker.1]: }
2020-11-11T09:10:52.638681+00:00 app[Worker.1]: {
2020-11-11T09:10:52.638683+00:00 app[Worker.1]: url: 'https://i.ytimg.com/vi/60ItHLz5WEA/maxresdefault.jpg',
2020-11-11T09:10:52.638684+00:00 app[Worker.1]: width: 1920,
2020-11-11T09:10:52.638684+00:00 app[Worker.1]: height: 1080
2020-11-11T09:10:52.638684+00:00 app[Worker.1]: }
If you want to get the thumbnail url from the thumbnail object you can use JSON.stringify
Something like this: JSON.stringify(info.videoDetails.thumbnail.thumbnails[0]);
the [0]
specifies that you want the first thumbnail (there's multiple in different sizes).
You can probably figure out how to get the url after that.