Advertisement
0xCor3

YTDL v2

Jun 19th, 2018
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.61 KB | None | 0 0
  1. <?php
  2. /* READ ME!
  3. /* Required Tools on This Script : wget, php5.6 - 7.1 [ cli ]
  4. /* Created By 0xCor3 | Security Ghost
  5. /* Thanks For Stackoverflow.com && Security Ghost */
  6. system("clear");
  7. $m="\033[1;31m";
  8. $k="\033[1;33m";
  9. $h="\033[1;32m";
  10. $b="\033[1;34m";
  11. $baseUrl = 'https://www.googleapis.com/youtube/v3/';
  12. $apiKey = 'AIzaSyA5vOzQg5uXEjEz3eLiahKrIvTcFpc7G8A';
  13. function banner(){
  14.     echo "\t=====================================\n";
  15.     echo "\t=         MAZTER YOUTUBE M4A        =\n";
  16.     echo "\t=      FROM CHANNEL DOWNLOADER      =\n";
  17.     echo "\t=     By 0xCor3 | Security Ghost    =\n";
  18.     echo "\t=====================================\n";
  19. }
  20.  
  21. function Grabmp3($id){
  22.         $ch = curl_init();
  23.         curl_setopt($ch, CURLOPT_URL, "http://saveitoffline.com/process/?url=https://www.youtube.com/watch?v=".$id."&type=json");
  24.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  25.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  26.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  27.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
  28.         $ex = curl_exec($ch);
  29.         $gLink = json_decode($ex);
  30.         $title = $gLink->title;
  31.         $dl = $gLink->urls[19]->id;
  32.         $hm = $title."|".$dl;
  33.         return($hm);
  34.        
  35.     }
  36. function loadz($url){
  37.         $ch = curl_init();
  38.         curl_setopt($ch, CURLOPT_URL, $url);
  39.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  40.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  41.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  42.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
  43.         $ex = curl_exec($ch);
  44.         curl_close($ch);
  45.         return($ex);
  46.     }
  47. function GInfo($apiKey,$channelId){
  48.     $m="\033[1;31m";
  49.     $k="\033[1;33m";
  50.     $h="\033[1;32m";
  51.     $b="\033[1;34m";
  52.     $r = loadz("https://www.googleapis.com/youtube/v3/channels?part=snippet&id={$channelId}&key={$apiKey}");
  53.     $dcd = json_decode($r);
  54.     if(preg_match("/description/i", $r)){
  55.         $title = $dcd->items[0]->snippet->title;
  56.         $curl = $dcd->items[0]->snippet->customUrl;
  57.         $desc = $dcd->items[0]->snippet->description;
  58.     }else{
  59.         echo $m."Channel Not FOUND Exiting...\n";
  60.         sleep(3);
  61.         exit();
  62.     }
  63.     $banner = "{$h}\n\n";
  64.     $banner.= "= Channel Name : ".$k.$title.$h."\n";
  65.     $banner.= "= Channel URL : {$b}https://www.youtube.com/c/".$curl.$h."\n";
  66.     $banner.= "+++++++++++ Channel Description ++++++++++\n";
  67.     $banner.= $m.$desc.$h."\n";
  68.     $banner.= "++++++++++++++++++++++++++++++++++++++++++\n";
  69.     $banner.= "\n\n";
  70.  
  71.     return($banner);
  72. }
  73.     banner()."\n";
  74.     echo "Channel ID : "; $channelId = trim(fgets(STDIN));
  75.     echo GInfo($apiKey,$channelId);
  76.     echo "Lanjut ? (y/n) : "; $lanjut = trim(fgets(STDIN));
  77.     if($lanjut == "y"){
  78.             $params = [
  79.                 'id'=> $channelId,
  80.                 'part'=> 'contentDetails',
  81.                 'key'=> $apiKey
  82.             ];
  83.             $url = $baseUrl . 'channels?' . http_build_query($params);
  84.             $json = json_decode(loadz($url), true);
  85.  
  86.             $playlist = $json['items'][0]['contentDetails']['relatedPlaylists']['uploads'];
  87.  
  88.             $params = [
  89.                 'part'=> 'snippet',
  90.                 'playlistId' => $playlist,
  91.                 'maxResults'=> '50',
  92.                 'key'=> $apiKey
  93.             ];
  94.             $url = $baseUrl . 'playlistItems?' . http_build_query($params);
  95.             $json = json_decode(loadz($url), true);
  96.  
  97.             $videos = [];
  98.             foreach($json['items'] as $video)
  99.                 $videos[] = $video['snippet']['resourceId']['videoId'];
  100.  
  101.             while(isset($json['nextPageToken'])){
  102.                 $nextUrl = $url . '&pageToken=' . $json['nextPageToken'];
  103.                 $json = json_decode(loadz($nextUrl), true);
  104.                 foreach($json['items'] as $video)
  105.                     $videos[] = $video['snippet']['resourceId']['videoId'];
  106.             }
  107.             $z = 1;
  108.             foreach ($videos as $linkid) {
  109.                 $rem = explode("|",Grabmp3($linkid));
  110.                 $l = trim($rem[1]);
  111.                 $t = trim($rem[0]);
  112.                 echo $k.$z++."). ".$k.$linkid." => ".$b.$t."\n";
  113.             }
  114.             echo $k."Download All? (y/n) : ".$h; $dls = trim(fgets(STDIN));
  115.             if($dls == "y"){
  116.                 foreach ($videos as $linkid){
  117.                     echo $k.$z++."). ".$k.$linkid." => ".$b.$t."\n";
  118.                     system("wget -O '$t.m4a' --trust-server-names '$l'");
  119.                 }
  120.             }else{
  121.                 echo $m."Okay, Iam Done. Exiting \n";
  122.                 sleep(1);
  123.                 exit();
  124.             }
  125.     }else{
  126.         echo $m."Okay, Exiting....\n";
  127.         sleep(2);
  128.         exit();
  129.     }
  130. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement