3 * Fetches bouqet information from the dreambox
5 * @author Christian Weiske <cweiske@cweiske.de>
6 * @license LGPL http://www.gnu.org/copyleft/lesser.html
13 * @param string $ip IP-address or hostname of the dreambox
14 * @param boolean $bEpgData If EPG data shall be fetched, too
16 * @return array Array of bouqets and the items
18 public static function fetchRadioBouqets($ip, $bEpgData = true)
20 return self::fetchBouqets(
22 //TODO: fetch from dreambox config.js
23 '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet',
26 }//public static function fetchRadioBouqets(..)
33 * @param string $ip IP-address or hostname of the dreambox
34 * @param boolean $bEpgData If EPG data shall be fetched, too
36 * @return array Array of bouqets and the items
38 public static function fetchTvBouqets($ip, $bEpgData = true)
40 return self::fetchBouqets(
42 //TODO: fetch from dreambox config.js
43 '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.tv" ORDER BY bouquet',
46 }//public static function fetchTvBouqets(..)
53 * @param string $ip IP-address or hostname of the dreambox
54 * @param string $sql SQL query to fetch bouqet from database
55 * @param boolean $bEpgData If EPG data shall be fetched, too
57 * @return array Array of bouqets (name is key) and the items (sub arrays)
59 public static function fetchBouqets($ip, $sql, $bEpgData = true)
61 $host = 'http://' . $ip;
62 $streamhost = 'http://' . $ip . ':8001';
63 $url_getServices = $host . "/web/getservices?sRef=";
64 $url_stream_playlist = $host . '/web/stream.m3u?ref=';
65 $url_bouqet_epg = $host . '/web/epgnow?bRef=';
66 $url_stream = $streamhost . '/';
69 $url = $url_getServices . urlencode($sql);
70 $radiobouqets = new SimpleXMLElement(
71 file_get_contents($url)
75 foreach ($radiobouqets->e2service as $bouqet) {
76 $strBouqetName = self::properBouqetName($bouqet->e2servicename);
77 $arBouqets[$strBouqetName] = array();
79 $strRef = $bouqet->e2servicereference;
80 $url = $url_getServices . urlencode($strRef);
81 $epgurl = $url_bouqet_epg . urlencode($strRef);
83 $stations = new SimpleXMLElement(
89 foreach ($stations->e2service as $station) {
90 $strStationRef = (string)$station->e2servicereference;
91 $arBouqets[$strBouqetName][$strStationRef] = array(
92 'name' => (string)$station->e2servicename,
93 'playlist' => $url_stream_playlist . self::encodeUrl($strStationRef),
94 'stream' => $url_stream . self::encodeUrl($strStationRef),
99 $epgs = new SimpleXMLElement(
100 file_get_contents($epgurl)
102 foreach ($epgs->e2event as $epg) {
103 $strStationRef = (string)$epg->e2eventservicereference;
104 $arBouqets[$strBouqetName][$strStationRef] = array_merge(
105 $arBouqets[$strBouqetName][$strStationRef],
107 'epgtitle' => (string)$epg->e2eventtitle,
108 'epgdescription' => (string)$epg->e2eventdescription,
109 'epgdescription2' => (string)$epg->e2eventdescriptionextendet,
117 }//public static function fetchRadioBouqets(..)
122 * Fix the given bouqet name, make it a nice readable one.
123 * Removes some special chars and spaces.
125 * @param string $name Bouqet name
127 * @return string Fixed bouqet name
129 protected static function properBouqetName($name)
131 return trim(preg_replace('#\(.+\)$#', '', $name));
132 }//protected static function properBouqetName(..)
136 protected static function encodeUrl($strUrl)
143 }//protected static function encodeUrl(..)