diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 2d6007bf..6133b28c 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -671,9 +671,8 @@ class Artist extends database_object implements library_item $trimmed = Catalog::trim_featuring($name); $name = $trimmed[0]; - if ($mbid == '') { - $mbid = null; - } + // If Ampache support multiple artists per song one day, we should also handle other artists here + $mbid = Catalog::trim_slashed_list($mbid); if (!$name) { $name = T_('Unknown (Orphaned)'); diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 58b16436..c84fa5b5 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1899,6 +1899,24 @@ abstract class Catalog extends database_object return $year; } + /** + * trim_slashed_list + * Return only the first item from / separated list + * @param string $string + * @return string + */ + public static function trim_slashed_list($string) + { + if ($string) { + $items = explode('/', $string); + $first = trim($items[0]); + } + if ($first == '') { + $first = null; + } + return $first; + } // trim_slashed_list + /** * trim_featuring * Splits artists featuring from the string diff --git a/lib/class/song.class.php b/lib/class/song.class.php index f68f7f98..9bf45628 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -384,10 +384,7 @@ class Song extends database_object implements media, library_item if (!isset($results['albumartist_id'])) { if ($albumartist) { // Multiple artist per songs not supported for now - if ($albumartist_mbid) { - $mbids = explode('/', $albumartist_mbid); - $albumartist_mbid = trim($mbids[0]); - } + $albumartist_mbid = Catalog::trim_slashed_list($albumartist_mbid); $albumartist_id = Artist::check($albumartist, $albumartist_mbid); } } else { @@ -396,10 +393,7 @@ class Song extends database_object implements media, library_item $artist_id = null; if (!isset($results['artist_id'])) { // Multiple artist per songs not supported for now - if ($artist_mbid) { - $mbids = explode('/', $artist_mbid); - $artist_mbid = trim($mbids[0]); - } + $artist_mbid = Catalog::trim_slashed_list($artist_mbid); $artist_id = Artist::check($artist, $artist_mbid); } else { $artist_id = intval($results['artist_id']);