Beispiel #1
0
function getFormatName($filedata)
{
    global $prefs;
    if ($prefs['player_backend'] == "mopidy" && !preg_match('/local:track:/', $filedata['file'])) {
        if (array_key_exists('Title', $filedata) && array_key_exists('Artist', $filedata)) {
            return concatenate_artist_names(array_unique(explode(';', $filedata['Artist']))) . ' - ' . $filedata['Title'];
        }
        if (array_key_exists('Title', $filedata)) {
            return $filedata['Title'];
        }
        if (array_key_exists('Album', $filedata)) {
            return "Album: " . $filedata['Album'];
        }
    }
    return basename(rawurldecode($filedata['file']));
}
Beispiel #2
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;
 }
Beispiel #3
0
 public function newItem($filedata)
 {
     global $prefs;
     // This should only be called from outside the tree.
     // This is the root object's pre-parser
     if (array_key_exists('playlist', $filedata)) {
         $decodedpath = $filedata['playlist'];
         $filedata['file_display_name'] = basename($decodedpath);
     } else {
         $decodedpath = rawurldecode($filedata['file']);
     }
     if ($prefs['ignore_unplayable'] && substr($decodedpath, 0, 12) == "[unplayable]") {
         return;
     }
     // All the different fixups for all the different mopidy backends
     // and their various random ways of doing things.
     if (preg_match('/podcast\\+http:\\/\\//', $decodedpath)) {
         $filedata['file_display_name'] = array_key_exists('Title', $filedata) ? $filedata['Title'] : basename($decodedpath);
         $filedata['file_display_name'] = preg_replace('/Album: /', '', $filedata['file_display_name']);
         $decodedpath = preg_replace('/podcast\\+http:\\/\\//', 'podcast/', $decodedpath);
     } else {
         if (preg_match('/:artist:/', $decodedpath)) {
             $filedata['file_display_name'] = concatenate_artist_names($filedata['Artist']);
             $decodedpath = preg_replace('/(.+?):(.+?):/', '$1/$2/', $decodedpath);
         } else {
             if (preg_match('/:album:/', $decodedpath)) {
                 $matches = array();
                 $a = preg_match('/(.*?):(.*?):(.*)/', $decodedpath, $matches);
                 $decodedpath = $matches[1] . "/" . $matches[2] . "/" . concatenate_artist_names($filedata['AlbumArtist']) . "/" . $matches[3];
                 $filedata['file_display_name'] = $filedata['Album'];
             } else {
                 if (preg_match('/local:track:/', $decodedpath)) {
                     $filedata['file_display_name'] = basename($decodedpath);
                     $decodedpath = preg_replace('/:track:/', '/', $decodedpath);
                 } else {
                     if (preg_match('/:track:/', $decodedpath)) {
                         $matches = array();
                         $a = preg_match('/(.*?):(.*?):(.*)/', $decodedpath, $matches);
                         $decodedpath = $matches[1] . "/" . $matches[2] . "/" . concatenate_artist_names($filedata['Artist']) . "/" . $filedata['Album'] . "/" . $matches[3];
                         $filedata['file_display_name'] = $filedata['Title'];
                     } else {
                         if (preg_match('/soundcloud:song\\//', $decodedpath)) {
                             $filedata['file_display_name'] = array_key_exists('Title', $filedata) ? $filedata['Title'] : basename($decodedpath);
                             $decodedpath = preg_replace('/soundcloud:song/', 'soundcloud/' . concatenate_artist_names($filedata['Artist']), $decodedpath);
                         } else {
                             if (preg_match('/^internetarchive:/', $decodedpath)) {
                                 $filedata['file_display_name'] = $filedata['Album'];
                                 $decodedpath = preg_replace('/internetarchive:/', 'internetarchive/', $decodedpath);
                             } else {
                                 if (preg_match('/youtube:video\\//', $decodedpath)) {
                                     $filedata['file_display_name'] = array_key_exists('Title', $filedata) ? $filedata['Title'] : basename($decodedpath);
                                     $decodedpath = preg_replace('/youtube:video/', 'youtube', $decodedpath);
                                 } else {
                                     if ($prefs['player_backend'] == "mopidy") {
                                         $filedata['file_display_name'] = array_key_exists('Title', $filedata) ? $filedata['Title'] : basename($decodedpath);
                                     } else {
                                         $filedata['file_display_name'] = basename($filedata['file']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $pathbits = explode('/', $decodedpath);
     $name = array_shift($pathbits);
     if (!array_key_exists($name, $this->children)) {
         $this->children[$name] = new mpdlistthing($name, $this);
     }
     $this->children[$name]->newChild($pathbits, $filedata);
 }