Youtube Video Download script HTML 100% working 2023
Sure! Here's an example of an HTML script that allows you to download YouTube videos:
html<!DOCTYPE html>
<html>
<head>
<title>YouTube Video Downloader</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<h1>YouTube Video Downloader</h1>
<input type="text" id="videoUrl" placeholder="Enter YouTube video URL">
<button onclick="downloadVideo()">Download</button>
<script>
function downloadVideo() {
var videoUrl = document.getElementById("videoUrl").value;
if (videoUrl) {
var videoId = getYouTubeVideoId(videoUrl);
if (videoId) {
var downloadUrl = "https://www.youtubeinmp3.com/fetch/?video=https://www.youtube.com/watch?v=" + videoId;
window.location.href = downloadUrl;
} else {
alert("Invalid YouTube video URL");
}
} else {
alert("Please enter a YouTube video URL");
}
}
function getYouTubeVideoId(url) {
var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match && match[2].length == 11) {
return match[2];
} else {
return null;
}
}
</script>
</body>
</html>
This script creates a simple web page with an input field for the YouTube video URL and a button to initiate the download. When the user clicks the "Download" button, the downloadVideo()
function is called. This function extracts the YouTube video ID from the URL and constructs a download URL using the YouTube-to-MP3 service. The download is then triggered by setting the window.location.href
to the download URL.
Please note that downloading YouTube videos may violate YouTube's terms of service or copyright laws in some cases. Make sure to use this script responsibly and only download videos that you have the right to access and use.
Comments
Post a Comment