mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-14 12:22:26 +00:00
discogs: Fixed detection of medium number for vinyl with one track per
side (A, B, C, ...). For such trackPosition, medium number was never updated. www.discogs.com/release/4071616 can now be imported correctly.
This commit is contained in:
parent
9aa9582974
commit
8e67c4ee4f
1 changed files with 31 additions and 22 deletions
|
@ -641,17 +641,29 @@ function parseDiscogsRelease(data) {
|
||||||
trackPosition = "";
|
trackPosition = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmp = trackPosition.match(/(\d+)(?:[\.-](\d+))?/);
|
// Possible track position:
|
||||||
|
// A1 or A => Vinyl or Cassette : guess releaseNumber from vinyl side
|
||||||
|
// 1-1 or 1.1 => releaseNumber.trackNumber
|
||||||
|
// 1 => trackNumber
|
||||||
|
var tmp = trackPosition.match(/(\d+|[A-Za-z])(?:[\.-](\d+))?/);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
tmp[1] = parseInt(tmp[1], 10);
|
tmp[1] = parseInt(tmp[1], 10);
|
||||||
var trackNumber = 1;
|
var trackNumber = 1;
|
||||||
var buggyTrackNumber = false;
|
var buggyTrackNumber = false;
|
||||||
var prevReleaseNumber = releaseNumber;
|
var prevReleaseNumber = releaseNumber;
|
||||||
|
|
||||||
|
if (Number.isInteger(tmp[1])) {
|
||||||
if (tmp[2]) { // 1-1, 1-2, 2-1, ... - we can get release number and track number from this
|
if (tmp[2]) { // 1-1, 1-2, 2-1, ... - we can get release number and track number from this
|
||||||
releaseNumber = tmp[1];
|
releaseNumber = tmp[1];
|
||||||
trackNumber = parseInt(tmp[2], 10);
|
trackNumber = parseInt(tmp[2], 10);
|
||||||
} else if (trackPosition.match(/^[A-Za-z]\d*$/)) { // Vinyl or cassette, handle it specially
|
} else if (tmp[1] <= lastPosition) { // 1, 2, 3, ... - We've moved onto a new medium
|
||||||
|
releaseNumber++;
|
||||||
|
trackNumber = tmp[1];
|
||||||
|
} else {
|
||||||
|
trackNumber = tmp[1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (trackPosition.match(/^[A-Za-z]\d*$/)) { // Vinyl or cassette, handle it specially
|
||||||
var code = trackPosition.charCodeAt(0);
|
var code = trackPosition.charCodeAt(0);
|
||||||
// A-Z
|
// A-Z
|
||||||
if (65 <= code && code <= 90) {
|
if (65 <= code && code <= 90) {
|
||||||
|
@ -661,15 +673,12 @@ function parseDiscogsRelease(data) {
|
||||||
code = code - (65 + 32);
|
code = code - (65 + 32);
|
||||||
}
|
}
|
||||||
releaseNumber = (code-code%2)/2+1;
|
releaseNumber = (code-code%2)/2+1;
|
||||||
|
lastPosition++;
|
||||||
} else if (trackPosition.match(/^[A-Za-z]+\d*$/)) { // Vinyl or cassette, handle it specially
|
} else if (trackPosition.match(/^[A-Za-z]+\d*$/)) { // Vinyl or cassette, handle it specially
|
||||||
// something like AA1, exemple : http://www.discogs.com/release/73531
|
// something like AA1, exemple : http://www.discogs.com/release/73531
|
||||||
// TODO: find a better fix
|
// TODO: find a better fix
|
||||||
buggyTrackNumber = true;
|
buggyTrackNumber = true;
|
||||||
} else if (tmp[1] <= lastPosition) { // 1, 2, 3, ... - We've moved onto a new medium
|
}
|
||||||
releaseNumber++;
|
|
||||||
trackNumber = tmp[1];
|
|
||||||
} else {
|
|
||||||
trackNumber = tmp[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (releaseNumber > release_formats.length) {
|
if (releaseNumber > release_formats.length) {
|
||||||
|
|
Loading…
Reference in a new issue