mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-14 04:12:28 +00:00
discogs: introduce artistNoNum() function and reduce code redundancy
This commit is contained in:
parent
1f55960600
commit
92626ce158
1 changed files with 10 additions and 4 deletions
|
@ -430,6 +430,12 @@ function cleanup_discogs_artist_credit(obj) {
|
|||
}
|
||||
}
|
||||
|
||||
// Returns the name without the numerical suffic Discogs adds as disambiguation
|
||||
// ie. "ABC (123)" -> "ABC"
|
||||
function artistNoNum(artist_name) {
|
||||
return artist_name.replace(/ \(\d+\)$/, "");
|
||||
}
|
||||
|
||||
// Analyze Discogs data and return a release object
|
||||
function parseDiscogsRelease(data) {
|
||||
|
||||
|
@ -445,8 +451,8 @@ function parseDiscogsRelease(data) {
|
|||
release.artist_credit = [];
|
||||
$.each(discogsRelease.artists, function(index, artist) {
|
||||
var ac = {
|
||||
'artist_name': artist.name.replace(/ \(\d+\)$/, ""),
|
||||
'credited_name': (artist.anv != "" ? artist.anv : artist.name.replace(/ \(\d+\)$/, "")),
|
||||
'artist_name': artistNoNum(artist.name),
|
||||
'credited_name': (artist.anv != "" ? artist.anv : artistNoNum(artist.name)),
|
||||
'joinphrase': decodeDiscogsJoinphrase(artist.join),
|
||||
'mbid': MBIDfromUrl(artist.resource_url, 'artist')
|
||||
};
|
||||
|
@ -593,8 +599,8 @@ function parseDiscogsRelease(data) {
|
|||
if (discogsTrack.artists) {
|
||||
$.each(discogsTrack.artists, function(index, artist) {
|
||||
var ac = {
|
||||
'artist_name': artist.name.replace(/ \(\d+\)$/, ""),
|
||||
'credited_name': (artist.anv != "" ? artist.anv : artist.name.replace(/ \(\d+\)$/, "")),
|
||||
'artist_name': artistNoNum(artist.name),
|
||||
'credited_name': (artist.anv != "" ? artist.anv : artistNoNum(artist.name)),
|
||||
'joinphrase': decodeDiscogsJoinphrase(artist.join),
|
||||
'mbid': MBIDfromUrl(artist.resource_url, 'artist')
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue