From bb83f406d68f2463c5fb48635a8e2d6a19d8322b Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Tue, 23 Jun 2015 01:54:37 +0200 Subject: [PATCH] discogs: make vinyl release number calculation even simpler Use basic binary to get rid of uppercase/lowercase issue. --- discogs_importer.user.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/discogs_importer.user.js b/discogs_importer.user.js index 27900d1..e4c2df4 100644 --- a/discogs_importer.user.js +++ b/discogs_importer.user.js @@ -663,12 +663,8 @@ function parseDiscogsRelease(data) { } } else { if (trackPosition.match(/^[A-Z]\d*$/i)) { // Vinyl or cassette, handle it specially - var code = trackPosition.toUpperCase().charCodeAt(0); - // A-Z - if (65 <= code && code <= 90) { - code = code - 65; - } - releaseNumber = (code-code%2)/2+1; + // A,B -> 1; C,D -> 2; E,F -> 3, etc... + releaseNumber = ((32|trackPosition.charCodeAt(0))-97>>1)+1; lastPosition++; } else if (trackPosition.match(/^[A-Z]+\d*$/i)) { // Vinyl or cassette, handle it specially // something like AA1, exemple : http://www.discogs.com/release/73531