import_functions: makeArtistCredits() now splits featuring or versus artists

This commit is contained in:
Laurent Monin 2015-06-13 15:18:04 +02:00
parent 162a402b27
commit 8c29ca5c3f

View file

@ -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)