Advertisement
Guest User

getting.php

a guest
Nov 20th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.37 KB | None | 0 0
  1. <?php
  2. require "init.php";
  3. $link = $_GET['link'];
  4.  
  5. parse_str($link, $urlData);
  6. $my_id = array_values($urlData)[0];
  7.  
  8. $videoFetchURL = "http://www.youtube.com/get_video_info?&video_id=" . $my_id . "&asv=3&el=detailpage&hl=en_US";
  9. $videoData = get($videoFetchURL);
  10.  
  11. parse_str($videoData, $video_info);
  12.  
  13. $video_info = json_decode(json_encode($video_info));
  14. if (!$video_info->status ===  "ok") {
  15.     die("error in fetching youtube video data");
  16. }
  17. $videoTitle = $video_info->title;
  18. $videoAuthor = $video_info->author;
  19. $videoDurationSecs = $video_info->length_seconds;
  20. $videoDuration = secToDuration($videoDurationSecs);
  21. $videoViews = $video_info->view_count;
  22.  
  23. //change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
  24. $videoThumbURL = "http://i1.ytimg.com/vi/{$my_id}/hqdefault.jpg";
  25.  
  26. if (!isset($video_info->url_encoded_fmt_stream_map)) {
  27.     die('No data found');
  28. }
  29.  
  30. $streamFormats = explode(",", $video_info->url_encoded_fmt_stream_map);
  31.  
  32. if (isset($video_info->adaptive_fmts)) {
  33.     $streamSFormats = explode(",", $video_info->adaptive_fmts);
  34.     $pStreams = parseStream($streamSFormats);
  35. }
  36.     $cStreams = parseStream($streamFormats);
  37.  
  38.  
  39. ?>
  40. <!DOCTYPE html>
  41. <html lang="en">
  42. <head>
  43.     <meta charset="UTF-8">
  44.     <title>YouTube Video Downloader</title>
  45.    
  46.     <!-- Bootstrap 4 -->
  47.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  48.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  49.  
  50. </head>
  51. <body style="font-family: Lato; ">
  52.     <div class="container-fluid" style="margin-top: 50px; margin-bottom: 150px;">
  53.         <div class="row">
  54.             <div class="col-md-6 offset-md-3" style="padding: 0; border: 1px solid #CCC; ">
  55.                 <a href="index.php"><img src="header.png" alt="Header Image" style="width: 100%"> </a>              
  56.             </div>
  57.         </div>
  58.         <div class="row">
  59.             <div class="col-md-6 offset-md-3" style="border: 1px solid #CCC; ">
  60.                 <br>
  61.                 <h4 style="font-weight: 300;padding-left: 10px;"><?php echo $videoTitle ?></h4>
  62.                 <br>
  63.                 <div class="row">
  64.                     <div class="col-md-4">
  65.                         <!-- Thumbnail -->
  66.                         <img src="<?php echo $videoThumbURL ;?>" alt="Video Thumbnail" style="width:100%;">
  67.                     </div>
  68.                     <div class="col-md-8">
  69.                         <h6 style="font-weight: 700;">Channel</h6>
  70.                         <h6 style="font-size: 80%;"><?php echo $videoAuthor; ?></h6>
  71.                         <h6 style="font-weight: 700;">Duration</h6>
  72.                         <h6 style="font-size: 80%;"><?php echo $videoDuration; ?></h6>
  73.                         <h6 style="font-weight: 700;">Views</h6>
  74.                         <h6 style="font-size: 80%;"><?php echo $videoViews; ?></h6>
  75.                     </div>
  76.                 </div>
  77.                 <hr>
  78.                 <div class="row">
  79.                     <div class="col-md-12">
  80.                         <h5 style="text-align: center;">Video+Audio Formats</h5>
  81.                         <br>
  82.                         <?php foreach ($cStreams as $stream): ?>
  83.                             <?php $stream = json_decode(json_encode($stream)) ;?>
  84.                             <div class="row" style="text-align: center;">
  85.                                 <div class="col-md-3"><?php echo $stream->type ?></div>
  86.                                 <div class="col-md-3"><?php echo $stream->quality ?></div>
  87.                                 <div class="col-md-3"><?php echo $stream->size ?></div>
  88.                                 <div class="col-md-3"><a href="<?php echo $stream->url; ?>" download ><button class="btn btn-sm btn-outline-success">Download</button></a></div>
  89.  
  90.                             </div>
  91.                         <?php endforeach ?>
  92.                     </div>
  93.                 </div>
  94.                 <?php if (isset($pStreams)): ?>
  95.                 <hr>    
  96.                 <div class="row">
  97.                     <div class="col-md-12">
  98.                         <h5 style="text-align: center;">Video+Audio Formats</h5>
  99.                         <br>
  100.                         <?php foreach ($pStreams as $stream): ?>
  101.                             <?php $stream = json_decode(json_encode($stream)) ;?>
  102.                             <div class="row" style="text-align: center;">
  103.                                 <div class="col-md-3"><?php echo $stream->type ?></div>
  104.                                 <div class="col-md-3"><?php echo $stream->quality ?></div>
  105.                                 <div class="col-md-3"><?php echo $stream->size ?></div>
  106.                                 <div class="col-md-3"><a href="<?php echo $stream->url; ?>" download ><button class="btn btn-sm btn-outline-success">Download</button></a></div>
  107.  
  108.                             </div>
  109.                         <?php endforeach ?>
  110.                     </div>
  111.                 </div>
  112.                 <?php endif ?>
  113.                 <hr>
  114.             </div>
  115.             <hr>
  116.            
  117.         </div>
  118.     </div>
  119. </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement