get_stored_playlists(true) as $pl) { print ''; } } else { do_playlist_header(); $c = 0; $player = new $PLAYER_TYPE(); foreach ($player->get_stored_playlists(false) as $pl) { logger::log("MPD PLAYLISTS", "Adding Playlist : ".$pl); add_playlist(rawurlencode($pl), htmlentities($pl), 'icon-doc-text', 'clickloadplaylist', true, $c, false, null); $c++; } $existingfiles = glob('prefs/userplaylists/*'); foreach($existingfiles as $file) { add_playlist(rawurlencode(file_get_contents($file)), htmlentities(basename($file)), 'icon-doc-text', 'clickloaduserplaylist', true, $c, true, null); $c++; } if (!$player->playlist_error) { sort($used_images); $imgs = glob('prefs/plimages/*'); sort($imgs); $unneeded = array_diff($imgs, $used_images); foreach ($unneeded as $img) { logger::log("PLAYLISTS", "Removing uneeded playlist image",$img); if (is_dir($img)) { rrmdir($img); } else { @unlink($img); } } } else { logger::fail("LOADPLAYLISTS", "Error when loading saved playlists"); } } function do_playlist_tracks($pl, $icon, $target) { global $PLAYER_TYPE; directoryControlHeader($target, $pl); playlistPlayHeader($pl, $pl); $player = new $PLAYER_TYPE(); $c = 0; if ($pl == '[Radio Streams]') { foreach ($player->get_stored_playlist_tracks('[Radio Streams]', 0) as list($class, $uri, $filedata)) { add_playlist(rawurlencode($uri), htmlentities(substr($uri, strrpos($uri, '#')+1, strlen($uri))), 'icon-radio-tower' ,'clicktrack', true, $c, false, $pl); $c++; } } else { foreach ($player->get_stored_playlist_tracks($pl, 0) as list($class, $uri, $filedata)) { switch ($filedata['domain']) { case "soundcloud": case "youtube": case "spotify": case "gmusic": $icon = "icon-".$filedata['domain']."-circled"; break; default; $icon = "icon-music"; break; } add_playlist(rawurlencode($uri), get_artist_track_title($filedata), $icon, $class, $PLAYER_TYPE::is_personal_playlist($pl), $c, false, $pl); $c++; } } } function get_artist_track_title($filedata) { if ($filedata['Album'] == ROMPR_UNKNOWN_STREAM) { return $filedata['file']; } else { if ($filedata['type'] == "stream") { return $filedata['Album']; } else { return htmlentities($filedata['Title']).'
'.htmlentities(format_artist($filedata['Artist'])).''; } } } function do_user_playlist_tracks($pl, $icon, $target) { logger::mark("USERPLAYLISTS", "Downloading remote playlist",$pl); // Use the MPD version of the playlist parser, since that parses all tracks, // which is what we want. require_once ("player/mpd/streamplaylisthandler.php"); require_once ("utils/getInternetPlaylist.php"); // Real bugger this one. // HACK ALERT // We've got a URL, but to get the playlist title and image we need the name of the playlist // Just gonna have to read all the user playlists until we find the right one. $snookcocker = glob('prefs/userplaylists/*'); $pl_name = $pl; foreach ($snookcocker as $file) { $lines = file($file); foreach ($lines as $line) { if (trim($line) == $pl) { $pl_name = basename($file); break 2; } } } $tracks = load_internet_playlist($pl, '', '', true); directoryControlHeader($target, $pl_name); playlistPlayHeader($pl, $pl_name); foreach ($tracks as $c => $track) { add_playlist( rawurlencode($track['TrackUri']), ($track['PrettyStream'] == '') ? $track['TrackUri'] : $track['PrettyStream'], 'icon-radio-tower', 'clicktrack', false, $c, false, $pl ); } } function add_playlist($link, $name, $icon, $class, $delete, $count, $is_user, $pl) { global $used_images; switch ($class) { case 'clickloadplaylist': case 'clickloaduserplaylist': $albumimage = new albumImage(array('artist' => "PLAYLIST", 'album' => $name)); $image = $albumimage->get_image_if_exists(); $i = dirname($albumimage->basepath); if (!in_array($i, $used_images)) { $used_images[] = $i; } $html = albumHeader(array( 'id' => 'pholder_'.md5($name), 'Image' => $image, 'Searched' => 1, 'AlbumUri' => null, 'Year' => null, 'Artistname' => '', 'Albumname' => $name, 'why' => 'whynot', 'ImgKey' => $albumimage->get_image_key(), 'userplaylist' => $class, 'plpath' => $link, 'class' => preg_replace('/clickload/', '', $class), 'expand' => true )); $out = addPlaylistControls($html, $delete, $is_user, $name); print $out->html(); break; case "clicktrack": print ''; print ''; print ''; break; case "clickcue": print '
'; print ''; print '
'.$name.'
'; print '
'; break; default: logger::error("MPD PLAYLISTS", "ERROR! Not permitted type passed to add_playlist",$class); break; } } function do_playlist_header() { print ''; } ?>