url = $url; $this->station = $station; $this->image = $image; $this->tracks = array(); $parts = explode(PHP_EOL, $data); $pointer = -1; foreach ($parts as $line) { $bits = explode("=", $line); if (preg_match('/File/', $bits[0])) { $pointer++; if ($pointer == 1) { break; } $this->tracks[$pointer] = array('TrackUri' => $url, 'PrettyStream' => ''); } if (preg_match('/Title/', $bits[0])) { $this->tracks[0]['PrettyStream'] = $bits[1]; } } } public function updateDatabase() { $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, $this->tracks); } else { logger::error("RADIO", "ERROR! Null station ID!"); header('HTTP/1.1 417 Expectation Failed'); exit(0); } } public function getTracksToAdd() { return array('add "'.format_for_mpd(htmlspecialchars_decode($this->url)).'"'); } } // // http://www.bbc.co.uk/5livesportsextra/ // BBC Radio 5 live sports extra // BBC // (c) British Broadcasting Corporation // // // // // // // // // class asxFile { public function __construct($data, $url, $station, $image) { logger::log("RADIO_PLAYLIST", "ASX File ".$url.", ".$station); $this->url = $url; $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml === false) { logger::warn("RADIO", "ERROR could not parse XML from",$url); header('HTTP/1.1 417 Expectation Failed'); exit(0); } $this->station = ($xml->TITLE != null && $xml->TITLE != '') ? $xml->TITLE : $station; $this->image = $image; $this->prettystream = ($xml->COPYRIGHT != null && $xml->COPYRIGHT != '') ? $xml->COPYRIGHT : ""; } public function updateDatabase() { logger::log("RADIO_PLAYLIST", " ASX File ".$this->url.", ".$this->station); $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, array(array('TrackUri' => $this->url, 'PrettyStream' => $this->prettystream))); } else { logger::error("RADIO", "ERROR! Null station ID!"); header('HTTP/1.1 417 Expectation Failed'); exit(0); } } public function getTracksToAdd() { return array('add "'.format_for_mpd(htmlspecialchars_decode($this->url)).'"'); } } // // I Love Radio (www.iloveradio.de) // http://www.iloveradio.de // // http://87.230.53.70:80/iloveradio1.mp3 // http://80.237.157.79:80/iloveradio1.mp3 // http://80.237.156.44:80/iloveradio1.mp3 // http://87.230.100.70:80/iloveradio1.mp3 // http://80.237.158.62:80/iloveradio1.mp3 // http://80.237.157.81:80/iloveradio1.mp3 // http://80.237.157.76:80/iloveradio1.mp3 // http://80.237.158.76:80/iloveradio1.mp3 // http://89.149.254.214:80/iloveradio1.mp3 // http://80.237.157.64:80/iloveradio1.mp3 // // class xspfFile { public function __construct($data, $url, $station, $image) { $this->url = $url; // Handle badly formed XML that some stations return $data = preg_replace('/ & /', ' & ', $data); $data = preg_replace('/ < /', ' < ', $data); $data = preg_replace('/ > /', ' > ', $data); $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml === false) { logger::warn("RADIO", "ERROR could not parse XML from",$url); header('HTTP/1.1 417 Expectation Failed'); exit(0); } $this->station = $xml->title != null ? $xml->title : $station; $this->image = $image; $prettystream = $xml->info != null ? $xml->info : ""; $this->tracks = array(); foreach($xml->trackList->track as $r) { $this->tracks[] = array('TrackUri' => (string) $r->location, 'PrettyStream' => $prettystream); } } public function updateDatabase() { $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, $this->tracks); } else { logger::error("RADIO", "ERROR! Null station ID!"); header('HTTP/1.1 417 Expectation Failed'); exit(0); } } public function getTracksToAdd() { $tracks = array(); foreach ($this->tracks as $r) { $tracks[] = 'add "'.format_for_mpd($r['TrackUri']).'"'; } return $tracks; } } // #This is a comment // // http://uk1.internet-radio.com:15614/ // or // #EXTM3U // #EXTINF:duration,Artist - Album // This works when Mopidy's unwrapper works, which it doesn't always. class m3uFile { public function __construct($data, $url, $station, $image) { logger::log("RADIO PLAYLIST", "New M3U Station ".$station); $this->url = $url; $this->station = $station; $this->image = $image; $this->tracks = array(); $this->prettystream = ''; $this->url_to_add = $url; $parts = explode(PHP_EOL, $data); foreach ($parts as $line) { if (preg_match('/#EXTINF:(.*?),(.*?)$/', $line, $matches)) { $this->prettystream = $matches[2]; } else if (preg_match('/^\#/', $line) || preg_match('/^\s*$/', $line)) { } else { $this->tracks[] = array('TrackUri' => trim($line), 'PrettyStream' => $this->prettystream); } } } public function updateDatabase() { $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, array(array('TrackUri' => $this->url_to_add, 'PrettyStream' => $this->prettystream))); } else { logger::error("RADIO", "ERROR! Null station ID!"); } } public function getTracksToAdd() { return array('add "'.format_for_mpd(htmlspecialchars_decode($this->url_to_add)).'"'); } } // [Reference] // Ref1=http://wmlive-lracl.bbc.co.uk/wms/england/lrleicester?MSWMExt=.asf // Ref2=http://212.58.252.33:80/wms/england/lrleicester?MSWMExt=.asf class asfFile { public function __construct($data, $url, $station, $image) { logger::log("RADIO PLAYLIST", "New ASF Station ".$station); $this->url = $url; $this->station = $station; $this->image = $image; $this->tracks = array(); } public function updateDatabase() { $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, array(array('TrackUri' => $this->url, 'PrettyStream' => ''))); } else { logger::error("RADIO", "ERROR! Null station ID!"); } } public function getTracksToAdd() { return array('add "'.format_for_mpd(htmlspecialchars_decode($this->url)).'"'); } } // Fallback - if it's not any of the above types, treat it as a single stream URL and see what happens. class possibleStreamUrl { public function __construct($url, $station, $image) { $this->url = $url; $this->station = $station; $this->image = $image; } public function updateDatabase() { $stationid = check_radio_station($this->url, $this->station, $this->image); if ($stationid) { check_radio_tracks($stationid, array(array('TrackUri' => $this->url, 'PrettyStream' => ''))); } else { logger::error("RADIO", "ERROR! Null station ID!"); } } public function getTracksToAdd() { return array('add "'.format_for_mpd(htmlspecialchars_decode($this->url)).'"'); } } ?>