Skip to content

Instantly share code, notes, and snippets.

@Amitind
Last active May 1, 2022 06:54
Show Gist options
  • Save Amitind/2d631e3b691b94dd4c8230bfe1628405 to your computer and use it in GitHub Desktop.
Save Amitind/2d631e3b691b94dd4c8230bfe1628405 to your computer and use it in GitHub Desktop.
$("#get").click(function() {
var ytl = $("#youtubeLink").val();
var yti = ytl.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
$("#msg").html("<h1>YouTube Thumbnail</h1><p><img src=\"http://i3.ytimg.com/vi/" + yti[1] + "/maxresdefault.jpg\" class=\"image\" /></p><p><img src=\"http://i3.ytimg.com/vi/" + yti[1] + "/hqdefault.jpg\" class=\"image\" /></p><h2>Image URL:</h2><br /><input name=\"imageURL\" id=\"copyimageURL\" class=\"text\" size=\"70\" type=\"text\" value=\"http://i3.ytimg.com/vi/" + yti[1] + "/maxresdefault.jpg\" onclick=\"this.select()\" readonly /><br /><input name=\"imageURL\" id=\"copyimageURL\" class=\"text\" size=\"70\" type=\"text\" value=\"http://i3.ytimg.com/vi/" + yti[1] + "/hqdefault.jpg\" onclick=\"this.select()\" readonly /><p>Right/Ctrl Click the image to download. Highlight the URL above and copy to your clipboard.</p>");
});
$("#copyimageURL").click(function() {
$(this).select();
});
// https://youtu.be/UHQPdP8qgrk
var ytl = "https://youtu.be/UHQPdP8qgrk"
var regexp = /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/
ytt = ytl.match(regexp)
ytid = ytt[1]
// console.log(ytid)
yttmax[1]= "http://i3.ytimg.com/vi/" + ytid[1] + "/maxresdefault.jpg"
ytthq = "http://i3.ytimg.com/vi/" + ytid[1] + "/hqdefault.jpg"
// console.log(yttmax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment