* @license LGPL http://www.gnu.org/copyleft/lesser.html */ class DreamboxBouqets { /** * Fetch radio bouqets * * @param string $ip IP-address or hostname of the dreambox * * @return array Array of bouqets and the items */ public static function fetchRadioBouqets($ip) { $host = 'http://' . $ip; $streamhost = 'http://' . $ip . ':8001'; $url_getServices = $host . "/web/getservices?sRef="; $url_stream_playlist = $host . '/web/stream.m3u?ref='; $url_bouqet_epg = $host . '/web/epgnow?bRef='; $url_stream = $streamhost . '/'; //TODO: fetch from dreambox config.js $bouqet_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet'; $url = $url_getServices . urlencode($bouqet_radio); $radiobouqets = new SimpleXMLElement( file_get_contents($url) ); $arBouqets = array(); foreach ($radiobouqets->e2service as $bouqet) { $strBouqetName = self::properBouqetName($bouqet->e2servicename); $arBouqets[$strBouqetName] = array(); $strRef = $bouqet->e2servicereference; $url = $url_getServices . urlencode($strRef); $epgurl = $url_bouqet_epg . urlencode($strRef); $stations = new SimpleXMLElement( file_get_contents( $url ) ); foreach ($stations->e2service as $station) { $strStationRef = (string)$station->e2servicereference; $arBouqets[$strBouqetName][$strStationRef] = array( 'name' => (string)$station->e2servicename, 'playlist' => $url_stream_playlist . $strStationRef, 'stream' => $url_stream . $strStationRef ); } $epgs = new SimpleXMLElement( file_get_contents($epgurl) ); foreach ($epgs->e2event as $epg) { $strStationRef = (string)$epg->e2eventservicereference; $arBouqets[$strBouqetName][$strStationRef] = array_merge( $arBouqets[$strBouqetName][$strStationRef], array( 'epgtitle' => (string)$epg->e2eventtitle, 'epgdescription' => (string)$epg->e2eventdescription, 'epgdescription2' => (string)$epg->e2eventdescriptionextendet, ) ); } } return $arBouqets; }//public static function fetchRadioBouqets(..) protected static function properBouqetName($name) { return trim(preg_replace('#\(.+\)$#', '', $name)); } } ?>