1

How can I download YouTube video Thumbnail to my machine by creating a blob file from the YouTube API

1

1 Answer 1

2

You can do this to fetch it:

const youtube = (function () {
    let video, results;

    const getThumbnail = function (url, size) {
        if (url == null) {
            return '';
        }
    
        size = (size == null) ? 'big' : size;
        results = url.match('[\\?&]v=([^&#]*)');
        video = (results == null) ? url : results[1];

        if (size == 'small') {
            return `http://img.youtube.com/vi/${video}/2.jpg`;
        }

        return `http://img.youtube.com/vi/${video}/0.jpg`;
    };

    return {
        thumbnail: getThumbnail
    };
}());




//Example of usage:

const thumbnail = youtube.thumbnail("http://www.youtube.com/watch?v=Tn6-PIqc4UM", "small")    

console.log(thumbnail); 
Sign up to request clarification or add additional context in comments.

4 Comments

Hey Alen can u please let me know what wrong in stackoverflow.com/questions/67265422/…
@virendraparade Page not found. I cannot open it.
can you try out this link: stackoverflow.com/questions/67269963/…
@virendraparade I think the problem is because you're trying to fetch this from localhost, if you try to do that from production, it will work. Can you try to solve your problem with this extension

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.