mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-11-10 13:14:16 +00:00
Better handling of Various Artists and other special artists
Let each script set the correct artist, instead of doing automagically in mbimport.
This commit is contained in:
parent
2bff7ff192
commit
603450ec4f
5 changed files with 57 additions and 29 deletions
|
@ -107,9 +107,10 @@ function retrieveReleaseInfo(release_url) {
|
|||
});
|
||||
|
||||
if (unique_artists.length > 4) {
|
||||
unique_artists = [ 'Various Artists' ];
|
||||
release.artist_credit = [ MBImport.specialArtist('various_artists') ];
|
||||
} else {
|
||||
release.artist_credit = MBImport.makeArtistCredits(unique_artists);
|
||||
}
|
||||
release.artist_credit = MBImport.makeArtistCredits(unique_artists);
|
||||
release.discs.push( {
|
||||
'tracks': tracks,
|
||||
'format': release.format
|
||||
|
|
|
@ -450,6 +450,9 @@ function parseDiscogsRelease(data) {
|
|||
'joinphrase': decodeDiscogsJoinphrase(artist.join),
|
||||
'mbid': MBIDfromUrl(artist.resource_url, 'artist')
|
||||
};
|
||||
if (artist.id == 194) { // discogs place holder for various
|
||||
ac = MBImport.specialArtist('various_artists', ac);
|
||||
}
|
||||
release.artist_credit.push(ac);
|
||||
});
|
||||
cleanup_discogs_artist_credit(release);
|
||||
|
|
|
@ -115,10 +115,10 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
var parsed_release_artist = $("#product_heading_artist").text().trim();
|
||||
if (parsed_release_artist == 'VARIOUS') {
|
||||
parsed_release_artist = 'Various Artists';
|
||||
release.artist_credit = [ MBImport.specialArtist('various_artists') ];
|
||||
} else {
|
||||
release.artist_credit = MBImport.makeArtistCredits([ parsed_release_artist ]);
|
||||
}
|
||||
var release_artists = [ parsed_release_artist ];
|
||||
release.artist_credit = MBImport.makeArtistCredits(release_artists);
|
||||
release.discs.push( {
|
||||
'tracks': tracks,
|
||||
'format': release.format
|
||||
|
|
|
@ -29,13 +29,10 @@ $(document).ready(function(){
|
|||
|
||||
function retrieveReleaseInfo(release_url) {
|
||||
|
||||
// Release artist
|
||||
var artist = $("article span[itemprop='byArtist'] meta[itemprop='name']").attr('content').trim();
|
||||
var various_artists = (artist == 'Various Artists');
|
||||
|
||||
// Release defaults
|
||||
var release = {
|
||||
artist_credit: MBImport.makeArtistCredits([artist]),
|
||||
artist_credit: '',
|
||||
title: $("h1[itemprop='name']").text().trim(),
|
||||
year: 0,
|
||||
month: 0,
|
||||
|
@ -52,6 +49,15 @@ function retrieveReleaseInfo(release_url) {
|
|||
discs: [],
|
||||
};
|
||||
|
||||
// Release artist
|
||||
var artist = $("article span[itemprop='byArtist'] meta[itemprop='name']").attr('content').trim();
|
||||
var various_artists = (artist == 'Various Artists');
|
||||
if (various_artists) {
|
||||
release.artist_credit = [ MBImport.specialArtist('various_artists') ];
|
||||
} else {
|
||||
release.artist_credit = MBImport.makeArtistCredits([artist]);
|
||||
}
|
||||
|
||||
// Tracks
|
||||
var tracks = [];
|
||||
$("#albumTracklist tr[itemprop='tracks']").each(function() {
|
||||
|
@ -75,17 +81,17 @@ function retrieveReleaseInfo(release_url) {
|
|||
track_artists.push($(this).text().trim());
|
||||
}
|
||||
);
|
||||
if (track_artists) {
|
||||
artists = track_artists;
|
||||
}
|
||||
if (!artists.length && various_artists) {
|
||||
artists = ['[unknown]'];
|
||||
}
|
||||
tracks.push({
|
||||
'artist_credit': MBImport.makeArtistCredits(artists),
|
||||
var ac = {
|
||||
'artist_credit': '',
|
||||
'title': trackname,
|
||||
'duration': tracklength
|
||||
});
|
||||
};
|
||||
if (!track_artists.length && various_artists) {
|
||||
ac.artist_credit = [ MBImport.specialArtist('unknown') ];
|
||||
} else {
|
||||
ac.artist_credit = MBImport.makeArtistCredits(track_artists);
|
||||
}
|
||||
tracks.push(ac);
|
||||
});
|
||||
|
||||
release.discs.push( {
|
||||
|
|
|
@ -61,6 +61,17 @@ var MBImport = (function() {
|
|||
|
||||
// --------------------------------------- publics ----------------------------------------- //
|
||||
|
||||
var special_artists = {
|
||||
various_artists: {
|
||||
name: 'Various Artists',
|
||||
mbid: '89ad4ac3-39f7-470e-963a-56509c546377'
|
||||
},
|
||||
unknown: {
|
||||
name: '[unknown]',
|
||||
mbid: '125ec42a-7229-4250-afc5-e057484327fe'
|
||||
}
|
||||
};
|
||||
|
||||
var url_types = {
|
||||
purchase_for_download: 74,
|
||||
download_for_free: 75,
|
||||
|
@ -71,6 +82,20 @@ var MBImport = (function() {
|
|||
license: 301
|
||||
}
|
||||
|
||||
function fnSpecialArtist(key, ac) {
|
||||
var credited_name = "";
|
||||
var joinphrase = "";
|
||||
if (typeof ac !== 'undefined') {
|
||||
joinphrase = ac.joinphrase;
|
||||
}
|
||||
return {
|
||||
'artist_name': special_artists[key].name,
|
||||
'credited_name': credited_name,
|
||||
'joinphrase': joinphrase,
|
||||
'mbid': special_artists[key].mbid
|
||||
};
|
||||
}
|
||||
|
||||
// compute HTML of search link
|
||||
function fnBuildSearchLink(release) {
|
||||
var parameters = searchParams(release);
|
||||
|
@ -255,16 +280,7 @@ var MBImport = (function() {
|
|||
});
|
||||
}
|
||||
});
|
||||
return credits.map(function (item) {
|
||||
var mappings = {
|
||||
'[unknown]': '125ec42a-7229-4250-afc5-e057484327fe',
|
||||
'Various Artists': '89ad4ac3-39f7-470e-963a-56509c546377'
|
||||
};
|
||||
if (!item.mbid && item.artist_name in mappings) {
|
||||
item.mbid = mappings[item.artist_name];
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return credits;
|
||||
}
|
||||
|
||||
// Try to guess release type using number of tracks, title and total duration (in millisecs)
|
||||
|
@ -389,6 +405,8 @@ var MBImport = (function() {
|
|||
ISO8601toMilliSeconds: fnISO8601toMilliSeconds,
|
||||
makeEditNote: fnMakeEditNote,
|
||||
searchUrlFor: fnSearchUrlFor,
|
||||
URL_TYPES: url_types
|
||||
URL_TYPES: url_types,
|
||||
SPECIAL_ARTISTS: special_artists,
|
||||
specialArtist: fnSpecialArtist
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue