コード例 #1
0
ファイル: backend.php プロジェクト: cyrilix/rompr
function send_list_updates($artist_created, $album_created, $ttid, $send = true)
{
    global $mysqlc, $returninfo, $prefs;
    if (!array_key_exists('inserts', $returninfo)) {
        $returninfo['inserts'] = array();
    }
    if ($artist_created !== false && $prefs['sortcollectionby'] == "artist") {
        debuglog("Artist " . $artist_created . " was created", "USER RATING", 8);
        // We had to create a new albumartist, so we send back the artist HTML header
        // We need to know the artist details and where in the list it is supposed to go.
        array_push($returninfo['inserts'], do_artists_from_database('a', $prefs['sortcollectionby'], $artist_created));
    } else {
        if ($album_created !== false) {
            debuglog("Album " . $album_created . " was created", "USER RATING", 8);
            // Find the artist
            $artistid = find_artist_from_album($album_created);
            if ($artistid === null) {
                debuglog("ERROR - no artistID found!", "USER RATING", 1);
            } else {
                array_push($returninfo['inserts'], do_albums_from_database('a', 'album', $artistid, $album_created, false));
            }
        } else {
            if ($ttid !== null) {
                debuglog("Track " . $ttid . " was modified", "USER RATING", 8);
                $albumid = find_album_from_track($ttid);
                if ($albumid === null) {
                    debuglog("ERROR - no albumID found!", "USER RATING", 1);
                } else {
                    array_push($returninfo['inserts'], array('type' => 'insertInto', 'where' => 'aalbum' . $albumid, 'html' => do_tracks_from_database('a', 'album', $albumid, true)));
                }
            }
        }
    }
    if ($send) {
        $returninfo['stats'] = alistheader(get_stat('ArtistCount'), get_stat('AlbumCount'), get_stat('TrackCount'), format_time(get_stat('TotalTime')));
        if ($ttid) {
            $returninfo['metadata'] = get_all_data($ttid);
        }
        print json_encode($returninfo);
    }
}
コード例 #2
0
ファイル: albums.php プロジェクト: cyrilix/rompr
         return false;
     }
     $why = $matches[1];
     $what = $matches[2];
     $who = $matches[3];
     $albumlink = get_albumlink($who);
     $cmd = 'find file "' . $albumlink . '"';
     debuglog("Doing Album Browse : " . $cmd, "MPD");
     prepareCollectionUpdate();
     doCollection($cmd, $domains);
     createAlbumsList();
     if (preg_match('/^.+?:album:/', $albumlink)) {
         print do_tracks_from_database($why, $what, $who, true);
     } else {
         $matches = array();
         $artistid = find_artist_from_album($who);
         // Remove the 'Artist Link' album as it's no longer relevant
         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])) . '"';