Advertisement
0xCor3

YTDL

Jun 19th, 2018
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <?php
  2. /* READ ME!
  3. /* Required on file : wget, php5.6 - 7.1 [ cli ]
  4. /* Created By 0xCor3 | Security Ghost
  5. /* Thanks For Stackoverflow.com && Security Ghost */
  6. function Grabmp3($id){
  7. $ch = curl_init();
  8. curl_setopt($ch, CURLOPT_URL, "http://saveitoffline.com/process/?url=https://www.youtube.com/watch?v=".$id."&type=json");
  9. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  10. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
  13. $ex = curl_exec($ch);
  14. $gLink = json_decode($ex);
  15. $title = $gLink->title;
  16. $dl = $gLink->urls[19]->id;
  17. $hm = $title." | ".$dl;
  18. return($hm);
  19.  
  20. }
  21. function loadz($url){
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL, $url);
  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. curl_close($ch);
  30. return($ex);
  31. }
  32. $baseUrl = 'https://www.googleapis.com/youtube/v3/';
  33. // https://developers.google.com/youtube/v3/getting-started
  34. $apiKey = 'AIzaSyA5vOzQg5uXEjEz3eLiahKrIvTcFpc7G8A';
  35. // If you don't know the channel ID see below
  36. $channelId = 'UCfMcMOvgflhwW3FQtLosn7Q';
  37.  
  38. $params = [
  39. 'id'=> $channelId,
  40. 'part'=> 'contentDetails',
  41. 'key'=> $apiKey
  42. ];
  43. $url = $baseUrl . 'channels?' . http_build_query($params);
  44. $json = json_decode(loadz($url), true);
  45.  
  46. $playlist = $json['items'][0]['contentDetails']['relatedPlaylists']['uploads'];
  47.  
  48. $params = [
  49. 'part'=> 'snippet',
  50. 'playlistId' => $playlist,
  51. 'maxResults'=> '50',
  52. 'key'=> $apiKey
  53. ];
  54. $url = $baseUrl . 'playlistItems?' . http_build_query($params);
  55. $json = json_decode(loadz($url), true);
  56.  
  57. $videos = [];
  58. foreach($json['items'] as $video)
  59. $videos[] = $video['snippet']['resourceId']['videoId'];
  60.  
  61. while(isset($json['nextPageToken'])){
  62. $nextUrl = $url . '&pageToken=' . $json['nextPageToken'];
  63. $json = json_decode(loadz($nextUrl), true);
  64. foreach($json['items'] as $video)
  65. $videos[] = $video['snippet']['resourceId']['videoId'];
  66. }
  67. $z = 1;
  68. foreach ($videos as $linkid) {
  69. $rem = explode("|",Grabmp3($linkid));
  70. $l = $rem[1];
  71. $t = $rem[0];
  72. echo $z++."). ".$linkid." => ".$l."<br>";
  73. system("wget --max-redirect 1 -c $l -O $t.m4a");
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement