Showing posts with label youtube video downloader. Show all posts
Showing posts with label youtube video downloader. Show all posts

YOUTUBE VIDEO DOWNLOAD SCRIPT

THIS IS WHOLE PAGE TO CREATE YOUR OWN PERSONAL YOUTUBE VIDEO DOWNLOADER


<!DOCTYPE html>
<html lang="en">
<head>
  <title>Video Downloader</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- for-mobile-apps -->
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>

<link rel="stylesheet" href="assets/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font/css/font-awesome.css">
<link rel="stylesheet" href="assets/css/jquery-ui.css">
<link rel="stylesheet" href="assets/css/main.css" type="text/css">

</head>
<body>
<?php include_once('header.php');

 include_once('nav.php'); ?>

<div class="col-md-12">
<div class="container">
<div class="table-responsive">
<form action="" method="get">
<table class="table table-bordered table-striped">
<tr>
<td style="vertical-align:middle" align="center">URL</td>
<td style="vertical-align:middle"><input type="text" name="yturl" class="form-control" placeholder="https://www.youtube.com/watch?v=ZQ_KW3KVx40"></td>
<td style="vertical-align:middle" align="center"><input type="submit" class="btn btn-danger"></td>
</tr>

</table>
</form>
</div>
</div>
</div>

<div class="col-md-12">
<?php
if (isset($_GET["yturl"])) {
$url = $_GET["yturl"];
$regex_pattern = "/(youtube.com|youtu.be)\/(watch)?(\?v=)?(\S+)?/";
$match;
if(preg_match($regex_pattern, $url, $match)){
$e=explode('=',$url);
$id = $e[1];
parse_str(file_get_contents('http://www.youtube.com/get_video_info?video_id='.$id), $video_data);
$streams = $video_data['url_encoded_fmt_stream_map'];
$streams = explode(',',$streams);
$cnt=count($streams);
$counter=1;
?>
<div class="col-md-12">
<div class="col-md-6">
<img src="https://img.youtube.com/vi/<?php echo $id; ?>/hqdefault.jpg" />
</div>
<div class="col-md-6">
<table class="table table-bordered">
<tr>
<th>Quality</th>
<th>Type</th>
<th>Action</th>
</tr>
  <?php

    foreach ($streams as $streamdata) {
print_r("<tr>",$counter);
parse_str($streamdata,$streamdata);
ksort($streamdata);
foreach($streamdata as $k => $v){
if($k=="itag"){ $k=""; $v="";}
if($k=="url"){ $v=urldecode($v);
echo '<td><a href="'.$v.'" class="btn btn-danger">Download</a></td>';
}
if($k=="type"){ $v=explode(";",$v); $v=$v[0]; 
echo '<td><strong>'.$v.'</strong></td>';
}
if($k=="quality"){  
echo '<td><strong>'.$v.'</strong></td>';
}
}
$counter = $counter+1;
print_r("</tr>");
}
}
else{ echo "Sorry, not a youtube Video URL"; }
}
?>
</table>
</div>
</div>
</div>