Exploring the Endless Possibilities of the Unknown YouTube thumbnail download
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Thumbnail Downloader</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.input-group {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.input-group input {
padding: 10px;
width: 70%;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
}
.input-group button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.thumbnail-container {
text-align: center;
margin-bottom: 20px;
}
.thumbnail-img {
max-width: 100%;
height: auto;
border-radius: 5px;
}
.error {
color: red;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h1>YouTube Thumbnail Downloader</h1>
<div class="input-group">
<input type="text" id="videoUrl" placeholder="Enter YouTube video URL">
<button onclick="getThumbnail()">Download Thumbnail</button>
</div>
<div class="thumbnail-container">
<img src="" id="thumbnailImg" class="thumbnail-img" alt="Thumbnail">
</div>
<p id="errorMsg" class="error"></p>
</div>
<script>
function getThumbnail() {
const videoUrl = document.getElementById('videoUrl').value;
const videoId = extractVideoId(videoUrl);
if(videoId) {
const imageUrl = `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`;
document.getElementById('thumbnailImg').src = imageUrl;
document.getElementById('errorMsg').innerText = '';
} else {
document.getElementById('thumbnailImg').src = '';
document.getElementById('errorMsg').innerText = 'Invalid YouTube video URL';
}
}
function extractVideoId(url) {
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
const match = url.match(regExp);
return (match && match[7].length === 11) ? match[7] : false;
}
</script>
</body>
</html>
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें