3 * Fetches bouqet information from the dreambox
5 * @author Christian Weiske <cweiske@cweiske.de>
12 * @param string $ip IP-address or hostname of the dreambox
14 * @return array Array of bouqets and the items
16 public static function fetchRadioBouqets($ip)
18 $host = 'http://' . $ip;
19 $streamhost = 'http://' . $ip . ':8001';
20 $url_getServices = $host . "/web/getservices?sRef=";
21 $url_stream_playlist = $host . '/web/stream.m3u?ref=';
22 //1%3A7%3A2%3A0%3A0%3A0%3A0%3A0%3A0%3A0%3A(type%20%3D%3D%202)%20FROM%20BOUQUET%20%22userbouquet.info_______________radio_.radio%22%20ORDER%20BY%20bouquet
23 $url_bouqet_epg = $host . '/web/epgnow?bRef=';
24 $url_stream = $streamhost . '/';
26 //TODO: fetch from dreambox config.js
27 $bouqet_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet';
30 $url = $url_getServices . urlencode($bouqet_radio);
31 $radiobouqets = new SimpleXMLElement(
32 file_get_contents($url)
36 foreach ($radiobouqets->e2service as $bouqet) {
37 $strBouqetName = self::properBouqetName($bouqet->e2servicename);
38 $arBouqets[$strBouqetName] = array();
40 $strRef = $bouqet->e2servicereference;
41 $url = $url_getServices . urlencode($strRef);
42 $epgurl = $url_bouqet_epg . urlencode($strRef);
44 $stations = new SimpleXMLElement(
49 foreach ($stations->e2service as $station) {
50 $strStationRef = (string)$station->e2servicereference;
51 $arBouqets[$strBouqetName][$strStationRef] = array(
52 'name' => (string)$station->e2servicename,
53 'playlist' => $url_stream_playlist . $strStationRef,
54 'stream' => $url_stream . $strStationRef
58 $epgs = new SimpleXMLElement(
59 file_get_contents($epgurl)
61 foreach ($epgs->e2event as $epg) {
62 $strStationRef = (string)$epg->e2eventservicereference;
63 $arBouqets[$strBouqetName][$strStationRef] = array_merge(
64 $arBouqets[$strBouqetName][$strStationRef],
66 'epgtitle' => (string)$epg->e2eventtitle,
67 'epgdescription' => (string)$epg->e2eventdescription,
68 'epgdescription2' => (string)$epg->e2eventdescriptionextendet,
76 }//public static function fetchRadioBouqets(..)
80 protected static function properBouqetName($name)
82 return trim(preg_replace('#\(.+\)$#', '', $name));