Ejemplo n.º 1
0
    case 'getfaveartists':
        print json_encode(get_fave_artists());
        break;
    case 'getcharts':
        $charts = array();
        $charts['Artists'] = get_artist_charts();
        $charts['Albums'] = get_album_charts();
        $charts['Tracks'] = get_track_charts();
        print json_encode($charts);
        break;
    case 'geturis':
        $uris = getItemsToAdd($uri, "");
        print json_encode($uris);
        break;
    case 'geturisfordir':
        $uris = getDirItems($uri);
        print json_encode($uris);
        break;
}
close_transaction();
close_mpd();
debuglog("---------------------------END----------------------", "USERRATING", 4);
function forcedUriOnly($u, $d)
{
    // Some mopidy backends - YouTube and SoundCloud - can return the same artist/album/track info
    // for multiple different tracks.
    // This gives us a problem because find_item will think they're the same.
    // So for those backends we always force urionly to be true
    debuglog("Checking the spanner monkey : " . $d, "USERRATINGS", 9);
    if ($u || $d == "youtube" || $d == "soundcloud") {
        return true;
Ejemplo n.º 2
0
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;
}