Example #1
0
function update_stream_playlist($url, $name, $image, $creator, $title, $type, $fname)
{
    $file = "";
    $found = false;
    $x = null;
    if ($image === null) {
        $image = "newimages/broadcast.svg";
    }
    $playlists = glob("prefs/*STREAM*.xspf");
    foreach ($playlists as $i => $file) {
        $x = simplexml_load_file($file);
        foreach ($x->trackList->track as $i => $track) {
            if ($track->location == $url && preg_match('/Unknown Internet Stream/', $track->album)) {
                debuglog("Found Stream To Update! - " . $file, "RADIO PLAYLISTS");
                $track->album = $name;
                $fp = fopen($file, 'w');
                if ($fp) {
                    fwrite($fp, $x->asXML());
                }
                fclose($fp);
                $found = true;
                break;
            }
        }
        if ($found) {
            break;
        }
    }
    if (!$found) {
        $xml = '<?xml version="1.0" encoding="utf-8"?>' . "<playlist>\n" . "<playlisturl></playlisturl>\n" . "<trackList>\n" . "<track>\n" . xmlnode('album', $name) . xmlnode('image', $image) . xmlnode('creator', $creator) . xmlnode('title', $title) . xmlnode('stream', $title) . xmlnode('type', $type) . xmlnode('location', $url) . "</track>\n" . "</trackList>\n" . "</playlist>";
        debuglog("Creating new playlist for stream " . $url);
        $newname = 'prefs/' . $fname . '_' . md5($url) . '.xspf';
        if (file_exists($newname)) {
            debuglog("Stream Playlist already exists!", "STREAMS");
        } else {
            file_put_contents($newname, $xml);
        }
    }
}
Example #2
0
 public function getTracks()
 {
     return array("<track>\n" . xmlnode('stream', "") . xmlnode('album', $this->station) . xmlnode('image', $this->image) . xmlnode('title', "") . xmlnode('type', "stream") . xmlnode('creator', $this->creator) . xmlnode('location', $this->url) . "</track>\n", $this->station);
 }