mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-11-10 13:14:16 +00:00
Discogs importer: append sub-track titles to main title
If we have an index titled "A" with 2 sub-tracks "B" and "C", set the track title to "A: B / C" Tested on http://www.discogs.com/release/5880212
This commit is contained in:
parent
0d4b481ac5
commit
45c0216ea0
1 changed files with 20 additions and 1 deletions
|
@ -357,7 +357,7 @@ function parseDiscogsRelease(data) {
|
||||||
if (discogsTrack.type_ == 'heading') {
|
if (discogsTrack.type_ == 'heading') {
|
||||||
heading = discogsTrack.title;
|
heading = discogsTrack.title;
|
||||||
return;
|
return;
|
||||||
} else if (discogsTrack.type_ != 'track') {
|
} else if (discogsTrack.type_ != 'track' && discogsTrack.type_ != 'index') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,8 +386,27 @@ function parseDiscogsRelease(data) {
|
||||||
// Track position and release number
|
// Track position and release number
|
||||||
var trackPosition = discogsTrack.position;
|
var trackPosition = discogsTrack.position;
|
||||||
|
|
||||||
|
// Handle sub-tracks
|
||||||
if (trackPosition == "" && discogsTrack.sub_tracks) {
|
if (trackPosition == "" && discogsTrack.sub_tracks) {
|
||||||
trackPosition = discogsTrack.sub_tracks[0].position;
|
trackPosition = discogsTrack.sub_tracks[0].position;
|
||||||
|
// Append titles of sub-tracks to main track title
|
||||||
|
var subtrack_titles = [];
|
||||||
|
$.each(discogsTrack.sub_tracks, function(subtrack_index, subtrack) {
|
||||||
|
if (subtrack.type_ != 'track') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (subtrack.title) {
|
||||||
|
subtrack_titles.push(subtrack.title);
|
||||||
|
} else {
|
||||||
|
subtrack_titles.push('[unknown]');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (subtrack_titles.length) {
|
||||||
|
if (track.title) {
|
||||||
|
track.title += ': ';
|
||||||
|
}
|
||||||
|
track.title += subtrack_titles.join(' / ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip special tracks
|
// Skip special tracks
|
||||||
|
|
Loading…
Reference in a new issue