Hello friends today I will tell you how to create a youtube video downloader tool with php
Follow just two steps and create you youtube video downloader tool
step1- create a index,php file (create youtube downloader)
<center>
<br>
<br>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>youtube video donwload</title>
<script type="text/javascript">
$(function(){
$("#sub").click(function() {
var valid =true;
var url =$("#url").val();
var express = new RegExp('^~^(?:https?://)?(?:www[.])?(?:youtube[.]com/watch[?]v=|youtu[.]be/)([^&]{11})~x$');
if(url == "" ){
$("#form").prev(".msg").html("<div class='alert alert-danger'>Enter a url first </div>");
valid = false;
}
if(express.test(url) ){
$("#form").prev(".msg").html("<div class='alert alert-danger'>entrer a valid url please</div>");
valid = false;
alert("not work");
}
return valid;
});
});
</script>
</head>
<body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 20%;
padding: 10px;
height: 600px; /* Should be removed. Only for demonstration */
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<br>
<br>
<b>
<h2>Youtube Video Downloader</h2></b>
<center><form method="post" action="download.php" id="form">
<img src="yt.jpg" height="200px" width="200px">
<br>
<br><h3>Enter Youtube video link</h3>
<br>
<input type="text" size="35" name="url" placeholder="https://www.youtube.com/watch?v=1oqlmtnbBuk" id="url"><br>
<input type="submit" name="down" value="Download" class="btn btn-primary" id="sub">
</form></center>
<p>Download Youtube Videos With Our Tool</p>
</body>
</html>
</center>
step2- create a download.php file
<center>
<br>
<br>
<?php
error_reporting(0);
if (isset($_POST['down'])) {
$url = $_POST['url'];
$id_video= explode("?v=", $url);
$id_video = substr($id_video[1],0,11);
/*echo "<pre>";
print_r($id_video);
echo "</pre>";
echo "$id_video";*/
$data = file_get_contents("https://www.youtube.com/get_video_info?video_id=$id_video ");
parse_str($data,$arr);
/*echo "<pre>";
print_r($arr);
echo "</pre>";*/
// for url
$urls =explode(",",$arr['url_encoded_fmt_stream_map']);
/*
foreach ($urls as $value) {
parse_str($value,$format);
echo "<pre>",print_r($format),"</pre>";
}*/
}else{
echo "not avialable";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>youtube video downloader tool</title>
</head>
<body>
<div class="container" style="margin-top: 200px">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary text-center">
<div class="panel-heading">
<h3 class="panel-title"><?=$arr['title'] ?></h3>
</div>
<div class="panel-body" >
<div class="row">
<div class="col-md-4">
<img class="thumbnail" src=<?=$arr['thumbnail_url'] ?>>
</div>
<img src="yt.jpg" height="200px" width="200px">
<div class="col-md-3">
<label for="Download">Download :</label>
<?php
foreach ($urls as $value) {
parse_str($value,$format);
echo "<a class='btn btn-primary' href='{$format[url]}&title={$arr[title]}'>{$format['quality']}</a><br><br>";
}
?>
<a href="<?php echo $url = $_POST['url']; ?>"> <?php echo $url = $_POST['url']; ?> </a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</center>
<br>
<br>
<?php
error_reporting(0);
if (isset($_POST['down'])) {
$url = $_POST['url'];
$id_video= explode("?v=", $url);
$id_video = substr($id_video[1],0,11);
/*echo "<pre>";
print_r($id_video);
echo "</pre>";
echo "$id_video";*/
$data = file_get_contents("https://www.youtube.com/get_video_info?video_id=$id_video ");
parse_str($data,$arr);
/*echo "<pre>";
print_r($arr);
echo "</pre>";*/
// for url
$urls =explode(",",$arr['url_encoded_fmt_stream_map']);
/*
foreach ($urls as $value) {
parse_str($value,$format);
echo "<pre>",print_r($format),"</pre>";
}*/
}else{
echo "not avialable";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>youtube video downloader tool</title>
</head>
<body>
<div class="container" style="margin-top: 200px">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary text-center">
<div class="panel-heading">
<h3 class="panel-title"><?=$arr['title'] ?></h3>
</div>
<div class="panel-body" >
<div class="row">
<div class="col-md-4">
<img class="thumbnail" src=<?=$arr['thumbnail_url'] ?>>
</div>
<img src="yt.jpg" height="200px" width="200px">
<div class="col-md-3">
<label for="Download">Download :</label>
<?php
foreach ($urls as $value) {
parse_str($value,$format);
echo "<a class='btn btn-primary' href='{$format[url]}&title={$arr[title]}'>{$format['quality']}</a><br><br>";
}
?>
<a href="<?php echo $url = $_POST['url']; ?>"> <?php echo $url = $_POST['url']; ?> </a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</center>
ConversionConversion EmoticonEmoticon