0 all existing channels will be searched //usefull if the dreambox channels overlap with one or more other sources function getxmltvids($dbhost,$dbuser,$dbpassword,$sourceid) { global $chanlist; $mysqli = new mysqli($dbhost,$dbuser,$dbpassword,"mythconverg"); if ($mysqli->connect_errno) { exit("Failed to connect to MySQL: " . $mysqli->connect_error); } $query="SELECT DISTINCT name,xmltvid FROM channel WHERE length(xmltvid)>0"; if(is_numeric($sourceid) && $sourceid>0) { $tmp=$mysqli->real_escape_string($sourceid); $query=$query." AND sourceid=$tmp"; } $res = $mysqli->query($query); while($row=$res->fetch_assoc()) { foreach($chanlist as $channel) { if($channel->name == $row["name"]) { $channel->xmltvid=$row["xmltvid"]; } } } } //defaults $host=''; $webifport=80; $streamport=8001; $bouquet='Favourites (TV)'; $sourceid=0; //database access //change as needed $mysqlserver='127.0.0.1'; $mysqluser='mythtv'; $mysqlpass='mythtv'; if(empty($_REQUEST)) { ?>
loadXML($contents); $xpath=new DOMXPath($doc); //$elements=$xpath->query('/e2servicelistrecursive/e2bouquet/e2servicename'); $services=$xpath->query("/e2servicelistrecursive/e2bouquet/e2servicelist/e2service[../../e2servicename='$bouquet']"); if(!is_null($services)) { //e2service $cnt=1; foreach($services as $service) { $srvref=""; $srvname=""; foreach($service->childNodes as $node) { if($node->nodeName=='e2servicereference') { $srvref=$node->nodeValue; } else if($node->nodeName=='e2servicename') { $srvname=$node->nodeValue; } } $channel=new channel(); $channel->name=$srvname; $channel->srvref=$srvref; $channel->channum=$cnt; //Try to find the serviceid. //Note that if you have grouped several channels on the dreambox this //wont work because the service reference from the dreambox doesn't //contain the serviceid. $srvrefparts=explode(":",$srvref); if(count($srvrefparts)>4) { $tmp=hexdec($srvrefparts[3]); if($tmp>0) { $channel->tsserviceid=$tmp; } } getxmltvids($mysqlserver,$mysqluser,$mysqlpass,$sourceid); $chanlist[]=$channel; $cnt++; } //create the m3u file //header('Content-type: audio/x-mpegurl'); //header('Content-Disposition: attachment; filename="channels.m3u"'); echo "#EXTM3U\n"; foreach($chanlist as $channel) { echo "#EXTINF:0,$channel->channum - $channel->name\n"; if(is_string($channel->xmltvid) && strlen($channel->xmltvid)>0) { echo "#EXTMYTHTV:xmltvid=$channel->xmltvid\n"; } if(is_int($channel->tsserviceid)) { echo "#EXTMYTHTV2:serviceid=$channel->tsserviceid\n"; } echo "http://$host:$streamport/$channel->srvref\n"; } } ?>