discogs: fix incorrect artist credit join phrases

https://github.com/murdos/musicbrainz-userscripts/issues/64
This commit is contained in:
Laurent Monin 2015-06-21 15:45:21 +02:00
parent c46b16dac6
commit 6e8b40af7f

View file

@ -421,6 +421,14 @@ function insertMBSection(release, current_page_key) {
// Parsing of Discogs data // // Parsing of Discogs data //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function cleanup_discogs_artist_credit(obj) {
// Fix some odd Discogs release (e.g. http://api.discogs.com/releases/1566223) that have a ',' join phrase after the last artist
// Discogs set a join phrase even there's only one artist or when extraartists is set (ie. remix)
var last = obj.artist_credit.length-1;
if (last == 0 || obj.artist_credit[last].joinphrase == ", ") {
obj.artist_credit[last].joinphrase = "";
}
}
// Analyze Discogs data and return a release object // Analyze Discogs data and return a release object
function parseDiscogsRelease(data) { function parseDiscogsRelease(data) {
@ -444,6 +452,7 @@ function parseDiscogsRelease(data) {
}; };
release.artist_credit.push(ac); release.artist_credit.push(ac);
}); });
cleanup_discogs_artist_credit(release);
// ReleaseGroup // ReleaseGroup
if (discogsRelease.master_url) { if (discogsRelease.master_url) {
@ -580,10 +589,7 @@ function parseDiscogsRelease(data) {
}; };
track.artist_credit.push(ac); track.artist_credit.push(ac);
}); });
// Fix some odd Discogs release (e.g. http://api.discogs.com/releases/1566223) that have a ',' join phrase after the last artist cleanup_discogs_artist_credit(track);
if (track.artist_credit[track.artist_credit.length-1].joinphrase == ", ") {
track.artist_credit[track.artist_credit.length-1].joinphrase = "";
}
} }
// Track position and release number // Track position and release number