Re: Re: Format for youtube playlists

Home › Forums › Help and Support › Format for youtube playlists › Re: Re: Format for youtube playlists

#27647
Matoking
Member

Thanks Tantric,

If anyone wants to use this, here is the source and a link to a working example on my box.


<?php
//DEFAULT PLAYLIST DO NOT LEAVE BLANK
//THIS IS USED IF NO PLAYLIST IS SPECIFIED
$playlist='';

if (array_key_exists('playlist',$_GET) && $_GET) {
$playlist=$_GET;
}

$url = 'http://www.youtube.com/view_play_list?p='.$playlist;
$html = file_get_contents($url);

$video_section;
$videos;
$events = null;
$data = null;

$pattern_video_link = '/.*?/s';

preg_match_all($pattern_video_link, $html, $videos);

$videos = $videos[0];

if (array_key_exists('shuffle',$_GET) && $_GET) {
shuffle($videos);
}
echo '#EXTM3U'."n";
for ($i=0; $i<count($videos); $i++) {
preg_match('/title="(?P[^"]*)" href="/(?Pwatch?v=[^&]*)&/s', $videos[$i], $videoData);<br /> echo '#EXTINF:0,'.html_entity_decode($videoData)."n";<br /> echo 'http://www.youtube.com/'.$videoData."n";<br /> }<br /> ?>

You can add a link to your onlinemedia.xml file like so:

Fell free to use my server to play your playlists, but do respect it. I do reserve the right to ban access if you abuse this service.