Beispiel #1
0
 function misc_substr2_array($t, $a)
 {
     return misc_substr2($t, $a[0], $a[1], $a[2]);
 }
Beispiel #2
0
 function youtube_get_download_urls($video_id, $use_tor = 0, $debug = 0)
 {
     // normalize
     $video_id = youtube_get_videoid($video_id);
     // DEBUG
     //  echo $video_id;
     if ($video_id == '') {
         return NULL;
     }
     $url = 'http://www.youtube.com/get_video_info?video_id=' . $video_id;
     // DEBUG
     //  echo $url."\n";
     /*
       if (misc_url_exists ($url) === true)
         {
           $h = get_headers ($url);
           // DEBUG
     //      print_r ($h);
           return $h[19];
         }
     */
     $page = misc_download2($url, $use_tor);
     // text/plain
     // DEBUG
     //  echo $page;
     $a = array();
     parse_str($page, $a);
     if ($debug == 1) {
         echo '<pre><tt>';
         print_r($a);
     }
     // DEBUG
     //  echo $a['status'];
     //  if (!isset ($a['fmt_url_map']))   // changed by yt in august 2011
     //    return NULL;
     if (!isset($a['url_encoded_fmt_stream_map'])) {
         return NULL;
     }
     $b = explode(',', $a['url_encoded_fmt_stream_map']);
     //  for ($i = 0; isset ($b[$i]); $i++)
     //    $b[$i] = substr ($b[$i], 4);
     $a = array_merge($a, $b);
     if ($debug == 1) {
         echo '<pre><tt>';
         print_r($a);
         exit;
     }
     // normalize
     for ($j = 0; isset($a[$j]); $j++) {
         $p = urldecode($a[$j]);
         // DEBUG
         //      echo $p."\n";
         $p = misc_substr2($p, 'url=', NULL, '; ');
         // DEBUG
         //      echo $p."\n";
         $a[$j] = $p;
     }
     //      echo '<pre><tt>';
     //      print_r ($a);
     //exit;
     $b = array();
     for ($j = 0; isset($a[$j]); $j++) {
         $b[] = $a[$j];
     }
     return $b;
 }