1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Merge pull request #1409 from SenorSmartyPants/MultipleArtists

Only create entry for first artist in Artists MB data. Doesn't create…
This commit is contained in:
Afterster 2016-10-18 07:15:58 +02:00 committed by GitHub
commit 297572d692
3 changed files with 22 additions and 11 deletions

View file

@ -671,9 +671,8 @@ class Artist extends database_object implements library_item
$trimmed = Catalog::trim_featuring($name); $trimmed = Catalog::trim_featuring($name);
$name = $trimmed[0]; $name = $trimmed[0];
if ($mbid == '') { // If Ampache support multiple artists per song one day, we should also handle other artists here
$mbid = null; $mbid = Catalog::trim_slashed_list($mbid);
}
if (!$name) { if (!$name) {
$name = T_('Unknown (Orphaned)'); $name = T_('Unknown (Orphaned)');

View file

@ -1899,6 +1899,24 @@ abstract class Catalog extends database_object
return $year; 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 * trim_featuring
* Splits artists featuring from the string * Splits artists featuring from the string

View file

@ -384,10 +384,7 @@ class Song extends database_object implements media, library_item
if (!isset($results['albumartist_id'])) { if (!isset($results['albumartist_id'])) {
if ($albumartist) { if ($albumartist) {
// Multiple artist per songs not supported for now // Multiple artist per songs not supported for now
if ($albumartist_mbid) { $albumartist_mbid = Catalog::trim_slashed_list($albumartist_mbid);
$mbids = explode('/', $albumartist_mbid);
$albumartist_mbid = trim($mbids[0]);
}
$albumartist_id = Artist::check($albumartist, $albumartist_mbid); $albumartist_id = Artist::check($albumartist, $albumartist_mbid);
} }
} else { } else {
@ -396,10 +393,7 @@ class Song extends database_object implements media, library_item
$artist_id = null; $artist_id = null;
if (!isset($results['artist_id'])) { if (!isset($results['artist_id'])) {
// Multiple artist per songs not supported for now // Multiple artist per songs not supported for now
if ($artist_mbid) { $artist_mbid = Catalog::trim_slashed_list($artist_mbid);
$mbids = explode('/', $artist_mbid);
$artist_mbid = trim($mbids[0]);
}
$artist_id = Artist::check($artist, $artist_mbid); $artist_id = Artist::check($artist, $artist_mbid);
} else { } else {
$artist_id = intval($results['artist_id']); $artist_id = intval($results['artist_id']);