function musicCollectionSpotifyPlaylistHack($monitor) { $dirs = array(); $playlists = do_mpd_command("listplaylists", true, true); if (array_key_exists('playlist', $playlists)) { foreach ($playlists['playlist'] as $pl) { debuglog("Scanning Playlist " . $pl, "COLLECTION", 8); fwrite($monitor, "\nScanning Playlist " . $pl); doMpdParse('listplaylistinfo "' . format_for_mpd($pl) . '"', $dirs, array("spotify")); } } }
function musicCollectionUpdate() { $monitor = fopen('prefs/monitor', 'w'); $dirs = array("/"); while (count($dirs) > 0) { $dir = array_shift($dirs); fwrite($monitor, "\nScanning Directory " . $dir); doMpdParse('lsinfo "' . format_for_mpd($dir) . '"', $dirs, null); } fwrite($monitor, "\nUpdating Database"); fclose($monitor); }
function doFileBrowse($path, $prefix) { global $connection, $prefs; debuglog("Browsing " . $path, "DIRBROWSER"); $parts = true; $foundfile = false; $filedata = array(); $dircount = 0; fputs($connection, 'lsinfo "' . format_for_mpd($path) . '"' . "\n"); while (!feof($connection) && $parts) { $parts = getline($connection); if (is_array($parts)) { $s = trim($parts[1]); if (substr($s, 0, 1) != ".") { switch ($parts[0]) { case "file": if (!$foundfile) { $foundfile = true; } else { if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") { printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']); } $filedata = array(); } $filedata[$parts[0]] = $parts[1]; break; case "playlist": if ($path != "") { // Ignore playlists located at the root. This is cleaner and makes more sense printPlaylistItem(basename($parts[1]), $parts[1]); } break; case "directory": printDirectoryItem($parts[1], basename($parts[1]), $prefix, $dircount, false); $dircount++; break; case "Title": case "Time": case "Artist": case "Album": $filedata[$parts[0]] = $parts[1]; break; } } } } if (array_key_exists('file', $filedata)) { if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") { printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']); } } }
function join_command_string($cmd) { $c = $cmd[0]; for ($i = 1; $i < count($cmd); $i++) { $c .= ' "' . format_for_mpd($cmd[$i]) . '"'; } return $c; }
public function getAllTracks($cmd) { $tracks = array(); foreach ($this->tracks as $track) { if (preg_match('/:track:/', $track->tags['file'])) { $tracks[] = $cmd . ' "' . format_for_mpd($track->tags['file']) . '"'; } } return $tracks; }
function getDirItems($path) { global $connection, $is_connected; debuglog("Getting Directory Items For " . $path, "GIBBONS", 5); $items = array(); $parts = true; $lines = array(); fputs($connection, 'lsinfo "' . format_for_mpd($path) . '"' . "\n"); // We have to read in the entire response then go through it // because we only have the one connection to mpd so this function // is not strictly re-entrant and recursing doesn't work unless we do this. while (!feof($connection) && $parts) { $parts = getline($connection); if ($parts === false) { debuglog("Got OK or ACK from MPD", "DIRBROWSER", 8); } else { $lines[] = $parts; } } foreach ($lines as $parts) { if (is_array($parts)) { $s = trim($parts[1]); if (substr($s, 0, 1) != ".") { $fullpath = ltrim($path . '/' . $s, '/'); switch ($parts[0]) { case "file": $items[] = $fullpath; break; case "directory": $items = array_merge($items, getDirItems($fullpath)); break; } } } } return $items; }
function get_tracks_from_stream_playlist($fname) { $retarr = array(); $x = simplexml_load_file($fname); foreach ($x->trackList->track as $i => $track) { $retarr[] = 'add "' . format_for_mpd($track->location) . '"'; } return $retarr; }
remove_album_from_database($who); do_albums_from_database($why, 'album', $artistid, false, true); } close_mpd(); } else { if (array_key_exists("rawterms", $_REQUEST)) { // Handle an mpd-style search request requiring tl_track format results include "player/mpd/connection.php"; include "collection/collection.php"; $domains = checkDomains($_REQUEST); $cmd = "search"; foreach ($_REQUEST['rawterms'] as $key => $term) { if ($key == "track_name") { $cmd .= ' title "' . format_for_mpd(html_entity_decode($term[0])) . '"'; } else { $cmd .= " " . $key . ' "' . format_for_mpd(html_entity_decode($term[0])) . '"'; } } debuglog("Search command : " . $cmd, "MPD SEARCH"); $doing_search = true; doCollection($cmd, $domains); print json_encode($collection->tracks_as_array()); close_mpd(); } else { if (array_key_exists('terms', $_REQUEST)) { // SQL database search request $domains = checkDomains($_REQUEST); include "player/mpd/connection.php"; include "collection/collection.php"; include "collection/dbsearch.php"; $doing_search = true;