Youtube Video Download Script
Extracts the video title & download URL from a youtube page and starts a download.
Copy this code and paste it in your HTML
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$url = (isset($_POST['url']) && !empty($_POST['url'])) ?
$_POST['url'] : false; if (!$url) {
echo "Please enter a URL.";
} else {
// Extract video title.
$vTitle_results_1 = explode('<title>', $source); $vTitle_results_2 = explode('</title>', $vTitle_results_1[1]);
// Extract video download URL.
$dURL_results_1 = explode('url_encoded_fmt_stream_map": "url=', $source); $dURL_results_2 = explode('\u0026quality', $dURL_results_1[1]);
// Force download of video.
header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-Type: video/webm"); header("Content-Transfer-Encoding: binary");
}
}
?>
<form method="post">
<label for="url">URL:</label>
<input type="text" name="url" value="" id="url">
<input type="submit" name="submit" value="Download">
</form>
Report this snippet
Comments
Subscribe to comments