Ejemplo n.º 1
0
 public function get_sort_artist()
 {
     global $prefs;
     $sortartist = null;
     if ($prefs['sortbycomposer'] && $this->tags['Composer'] !== null) {
         if ($prefs['composergenre'] && $this->tags['Genre'] && checkComposerGenre($this->tags['Genre'], $prefs['composergenrename'])) {
             $sortartist = $this->tags['Composer'];
         } else {
             if (!$prefs['composergenre']) {
                 $sortartist = $this->tags['Composer'];
             }
         }
     }
     if ($sortartist == null) {
         if ($this->tags['AlbumArtist'] != null) {
             $sortartist = $this->tags['AlbumArtist'];
         } else {
             if ($this->tags['Artist'] != null) {
                 $sortartist = $this->tags['Artist'];
             } else {
                 if ($this->tags['station'] != null) {
                     $sortartist = $this->tags['station'];
                 }
             }
         }
     }
     $sortartist = concatenate_artist_names($sortartist);
     //Some discogs tags have 'Various' instead of 'Various Artists'
     if ($sortartist == "Various") {
         $sortartist = "Various Artists";
     }
     return $sortartist;
 }
Ejemplo n.º 2
0
function outputPlaylist()
{
    global $playlist;
    global $prefs;
    global $foundartists;
    $output = array();
    foreach ($playlist as $track) {
        // Track artists are held in the track object as an array
        $c = $track->get_artist_string();
        $t = $track->tags['Title'];
        // We can't return NULL in the JSON data for some reason that escapes me
        if ($c === null) {
            $c = "";
        }
        if ($t === null) {
            $t = "";
        }
        $info = array("title" => $t, "album" => $track->albumobject->name, "creator" => $c, "albumartist" => $track->albumobject->artist, "compilation" => $track->albumobject->isCompilation() ? "yes" : "no", "duration" => $track->tags['Time'], "type" => $track->tags['type'], "date" => $track->albumobject->getDate(), "tracknumber" => $track->tags['Track'], "station" => $track->tags['station'], "disc" => $track->tags['Disc'], "location" => $track->tags['file'], "backendid" => (int) $track->tags['Id'], "dir" => rawurlencode($track->albumobject->folder), "key" => $track->albumobject->getKey(), "image" => $track->albumobject->getImage('asdownloaded'), "trackimage" => $track->getImage(), "stream" => $track->tags['stream'], "playlistpos" => $track->tags['Pos'], "genre" => $track->tags['Genre'], "metadata" => array("iscomposer" => 'false', "artists" => array(), "album" => array("name" => $track->albumobject->name, "artist" => $track->albumobject->artist, "musicbrainz_id" => $track->albumobject->musicbrainz_albumid, "uri" => $track->getAlbumUri(null)), "track" => array("name" => $track->tags['Title'], "musicbrainz_id" => $track->tags['MUSICBRAINZ_TRACKID'])));
        $foundartists = array();
        // All kinds of places we get artist names from:
        // Composer, Performer, Track Artist, Album Artist
        // Note that we filter duplicates
        // This creates the metadata array used by the info panel and nowplaying -
        // Metadata such as scrobbles and ratings will still use the Album Artist
        if ($prefs['displaycomposer']) {
            // The user has chosen to display Composer/Perfomer information
            // Here check:
            // a) There is composer/performer information AND
            // bi) Specific Genre Selected, Track Has Genre, Genre Matches Specific Genre OR
            // bii) No Specific Genre Selected, Track Has Genre
            if (($track->tags['Composer'] !== null || $track->tags['Performer'] !== null) && ($prefs['composergenre'] && $track->tags['Genre'] && checkComposerGenre($track->tags['Genre'], $prefs['composergenrename']) || !$prefs['composergenre'] && $track->tags['Genre'])) {
                // Track Genre matches selected 'Sort By Composer' Genre
                // Display Compoer - Performer - AlbumArtist
                do_composers($track, $info);
                do_performers($track, $info);
                // The album artist probably won't be required in this case, but use it just in case
                do_albumartist($track, $info);
                // Don't do track artist as with things tagged like this this is usually rubbish
            } else {
                // Track Genre Does Not Match Selected 'Sort By Composer' Genre
                // Or there is no composer/performer info
                // Do Track Artist - Album Artist - Composer - Performer
                do_track_artists($track, $info);
                do_albumartist($track, $info);
                do_performers($track, $info);
                do_composers($track, $info);
            }
            if ($track->tags['Composer'] !== null || $track->tags['Performer'] !== null) {
                $info['metadata']['iscomposer'] = 'true';
            }
        } else {
            // The user does not want Composer/Performer information
            do_track_artists($track, $info);
            do_albumartist($track, $info);
        }
        if (count($info['metadata']['artists']) == 0) {
            array_push($info['metadata']['artists'], array("name" => "", "musicbrainz_id" => ""));
        }
        array_push($output, $info);
    }
    $o = json_encode($output);
    print $o;
    ob_flush();
    file_put_contents(ROMPR_PLAYLIST_FILE, $o);
}