mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2025-03-04 14:27:14 +00:00
import_functions: makeArtistCredits() now splits featuring or versus artists
This commit is contained in:
parent
162a402b27
commit
8c29ca5c3f
1 changed files with 30 additions and 1 deletions
|
@ -216,7 +216,36 @@ var MBReleaseImportHelper = (function() {
|
|||
} else if (artists.length == 2) {
|
||||
artists[0].joinphrase = ' & ';
|
||||
}
|
||||
return artists;
|
||||
var credits = [];
|
||||
// re-split artists if featuring or vs
|
||||
artists.map(function (item) {
|
||||
var c = item.artist_name.replace(/\s*(?:feat\.?|ft\.?|featuring)\s+/gi, ' feat. ');
|
||||
c = c.replace(/\s*\(( feat. )([^\)]+)\)/g, '$1$2');
|
||||
c = c.replace(/\s+(?:versus|vs\.?)\s+/gi, ' vs. ');
|
||||
c = c.replace(/\s+/g, ' ');
|
||||
var splitted = c.split(/( feat\. | vs\. )/);
|
||||
if (splitted.length == 1) {
|
||||
credits.push(item); // nothing to split
|
||||
} else {
|
||||
var new_items = [];
|
||||
var n = 0;
|
||||
for (var i = 0; i < splitted.length; i++) {
|
||||
if (n && (splitted[i] == ' feat. ' || splitted[i] == ' vs. ')) {
|
||||
new_items[n-1].joinphrase = splitted[i];
|
||||
} else {
|
||||
new_items[n++] = {
|
||||
artist_name: splitted[i].trim(),
|
||||
joinphrase: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
new_items[n-1].joinphrase = item.joinphrase;
|
||||
new_items.map(function (newit) {
|
||||
credits.push(newit)
|
||||
});
|
||||
}
|
||||
});
|
||||
return credits;
|
||||
}
|
||||
|
||||
// Try to guess release type using number of tracks, title and total duration (in millisecs)
|
||||
|
|
Loading…
Add table
Reference in a new issue