Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. header('Content-type: application/json');
  4. $ip = $_SERVER['REMOTE_ADDR'];
  5. function scrap($url) {
  6.  $curl = curl_init($url);
  7.  curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36");
  8.  curl_setopt($curl, CURLOPT_FAILONERROR, true);
  9.  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  10.  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  11.  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  12.   curl_setopt($curl, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));
  13.  $html = curl_exec($curl);
  14.  curl_close($curl);
  15.  return $html;
  16. }
  17. $g_id = $_GET["id"];
  18. $video_link = "https://drive.google.com/file/d/".$g_id."/view";
  19. $scrap_page = scrap($video_link);
  20. preg_match('/google\.com\/file\/d\/([^\&\?\/]+)/', $video_link, $id);
  21. $values = $id[1];
  22. $dt = file_get_contents("https://docs.google.com/get_video_info?docid=$values");
  23. $x = explode("&",$dt);
  24. $t = array(); $g = array(); $h = array();
  25. foreach($x as $r){
  26.     $c = explode("=",$r);
  27.     $n = $c[0]; $v=$c[1];
  28.     $y = urldecode($v);
  29.     $t[$n] = $v;
  30. }
  31. $streams = explode(',',urldecode($t['url_encoded_fmt_stream_map']));
  32. foreach($streams as $dt){
  33.     $x = explode("&",$dt);
  34.     foreach($x as $r){
  35.         $c = explode("=",$r);
  36.         $n = $c[0]; $v = $c[1];
  37.         $h[$n] = urldecode($v);
  38.     }
  39.     $g[] = $h;
  40. }
  41. for( $i= 0 ; $i <= 10 ; $i++ ){
  42.  $quality = $g[$i]['itag'];
  43.  if($quality == '18'){
  44.   $file_sd = $g[$i]['url'];
  45.  }$quality = $g[$i]['itag'];
  46.  if($quality == '22'){
  47.   $file_hd = $g[$i]['url'];
  48.  }$quality = $g[$i]['itag'];
  49.  if($quality == '37'){
  50.   $file_full_hd = $g[$i]['url'];
  51.  }
  52. }
  53. $regex = '/<meta property="og:image" content="(.+?)">/';
  54. preg_match($regex,$scrap_page,$match);
  55. $img = $match[1];
  56. $regex2 = '/,\["title","(.+?)"]/';
  57. preg_match($regex2,$scrap_page,$match2);
  58. $title = $match2[1];
  59. $array = array("file"=> $file_full_hd,"file_md"=>$file_hd,"file_sd"=>$file_sd,"img"=>$img,"title"=>$title);
  60. echo json_encode($array);
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement