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; }
function widget_video_youtube_playlist($video_urls, $width = 425, $height = 344, $ratio = NULL, $autoplay = 0, $hq = 0, $loop = 0) { $p = ''; //<script src="http://www.google.com/jsapi"></script> $p .= ' <script type="text/javascript"> function widget_video_youtube_next () { var e = document.getElementById (\'widget_video_youtube\'); // var e = document.getElementById (\'ytplayer\'); // var e = ytplayer; var debug = document.getElementById (\'debug\'); debug.innerHTML = e.getPlayerState ()+\'\'; if (e.getPlayerState () == 1) // video is still playing return; if (typeof this.pos == \'undefined\') this.pos = 0; var a = new Array ('; for ($i = 0; isset($video_urls[$i]); $i++) { if ($i > 0) { $p .= ', '; } $p .= '\'' . youtube_get_videoid($video_urls[$i]) . '\''; } $p .= ' ); // restart // if (this.pos == a.length) // this.pos = 0; e.loadVideoById (a[this.pos++], 0); e.playVideo (); // e.loadVideoById (\'Nh6siIPTN3o\', 0); // e.playVideo (); // e.loadVideoById (\'R1Z7plEWGgQ\', 0); // e.playVideo (); } window.onload = function () //function widget_video_youtube_start() { setInterval (\'widget_video_youtube_next()\', 500); } </script> <div id="debug"></div> '; $script = $p; //http://code.google.com/apis/youtube/player_parameters.html // $url = 'http://www.youtube.com/v/' // .$video_url $url = 'http://www.youtube.com/apiplayer?enablejsapi=1' . '&fs=1' . '&showinfo=0' . '&showsearch=0' . '&border=0'; $o = array(array('width', $width), array('height', $height)); $p = array(array('movie', $url), array('autoplay', $autoplay ? 'true' : 'false')); $e = array(array('id', 'widget_video_youtube'), array('src', $url), array('type', 'application/x-shockwave-flash'), array('width', $width), array('height', $height), array('autoplay', $autoplay ? 'true' : 'false')); return $script . widget_media_object_func($o, $p, $e); }
fileSize="12216320" type="video/quicktime" medium="video" isDefault="true" expression="full" bitrate="128" framerate="25" samplingrate="44.1" channels="2" duration="185" height="200" width="300" lang="en" /> */ // direct download $id = youtube_get_videoid($a['item'][$i]['link']); $b = youtube_get_download_urls($id, 0, $debug); for ($j = 0; isset($b[$j]); $j++) { if (in_array($output, array('pls', 'm3u'))) { $a['item'][$i]['media:content_' . $j . '_url'] = urlencode($b[$j]); } else { $a['item'][$i]['media:content_' . $j . '_url'] = $b[$j]; } $a['item'][$i]['media:content_' . $j . '_medium'] = 'video'; // $a['item'][$i]['media:content_'.$j.'_duration'] = $a['item'][$i]['media:duration']; // $a['item'][$i]['media:content_'.$j.'_width'] = 400; // $a['item'][$i]['media:content_'.$j.'_height'] = 300; } // HACK: enrich with information from wikipedia? // $a['item'][$i]['rsscache:wikipedia'] = }