diff --git a/discogs_importer.user.js b/discogs_importer.user.js index 51b6245..23ab9e6 100644 --- a/discogs_importer.user.js +++ b/discogs_importer.user.js @@ -840,6 +840,7 @@ function parseDiscogsRelease(discogsRelease) { let releaseNumber = 1; let lastPosition = 0; $.each(discogsRelease.tracklist, function (index, discogsTrack) { + let tracks = []; if (discogsTrack.type_ === 'heading') { heading = discogsTrack.title; return; @@ -881,14 +882,33 @@ function parseDiscogsRelease(discogsRelease) { if (subtrack.type_ !== 'track') { return; } + const position = subtrack.position || ''; + const isSubPosition = /^(.*\d)(?:\.(?:\d+|[a-z])|[a-z])$/i.test(position); + + if (isSubPosition) { + if (subtrack.duration) { + subtrack_total_duration += MBImport.hmsToMilliSeconds(subtrack.duration); + } + if (subtrack.title) { + subtrack_titles.push(subtrack.title); + } else { + subtrack_titles.push('[unknown]'); + } + return; + } + let track_new = new Object(); if (subtrack.duration) { + track_new.duration = MBImport.hmsToMilliSeconds(subtrack.duration); subtrack_total_duration += MBImport.hmsToMilliSeconds(subtrack.duration); } if (subtrack.title) { + track_new.title = `${track.title}: ${subtrack.title}`; + track_new.artist_credit = track.artist_credit; subtrack_titles.push(subtrack.title); } else { subtrack_titles.push('[unknown]'); } + tracks.push(track_new); }); if (subtrack_titles.length) { if (track.title) { @@ -977,7 +997,13 @@ function parseDiscogsRelease(discogsRelease) { // Trackposition is empty e.g. for release title if (trackPosition !== '' && trackPosition != null) { - release.discs[discindex].tracks.push(track); + if (tracks.length > 0) { + for (var i = 0; i < tracks.length; i++) { + release.discs[discindex].tracks.push(tracks[i]); + } + } else { + release.discs[discindex].tracks.push(track); + } } if (buggyTrackNumber && !release.maybe_buggy) { diff --git a/tests/discogs/snapshots/1156598.json b/tests/discogs/snapshots/1156598.json index 0e6c936..26613ea 100644 --- a/tests/discogs/snapshots/1156598.json +++ b/tests/discogs/snapshots/1156598.json @@ -27,10 +27,36 @@ "number": "A4" }, { - "title": "Lizard: Prince Rupert Awakes / Bolero - The Peacock's Tale / The Battle Of Glass Tears (Including:) / Dawn Song / Last Skirmish / Prince Rupert's Lament / Big Top", - "duration": 1344000, - "artist_credit": [], - "number": "" + "duration": 274000, + "title": "Lizard: Prince Rupert Awakes", + "artist_credit": [] + }, + { + "duration": 390000, + "title": "Lizard: Bolero - The Peacock's Tale", + "artist_credit": [] + }, + { + "duration": 655000, + "title": "Lizard: The Battle Of Glass Tears (Including:)", + "artist_credit": [] + }, + { + "title": "Lizard: Dawn Song", + "artist_credit": [] + }, + { + "title": "Lizard: Last Skirmish", + "artist_credit": [] + }, + { + "title": "Lizard: Prince Rupert's Lament", + "artist_credit": [] + }, + { + "duration": 65000, + "title": "Lizard: Big Top", + "artist_credit": [] } ], "format": "12\" Vinyl" diff --git a/tests/discogs/snapshots/15313328.json b/tests/discogs/snapshots/15313328.json index 62d57db..2694e81 100644 --- a/tests/discogs/snapshots/15313328.json +++ b/tests/discogs/snapshots/15313328.json @@ -3,8 +3,23 @@ { "tracks": [ { - "title": "Symphony No 3 In E Flat Major, Op 55 'Eroica' (1803): Allegro Con Brio / Marcia Funebre: Adagio Assi / Scherzo And Trio: Allegro Vivace / Finale: Allegro Molto", - "duration": 2953000, + "duration": 1070000, + "title": "Symphony No 3 In E Flat Major, Op 55 'Eroica' (1803): Allegro Con Brio", + "artist_credit": [] + }, + { + "duration": 862000, + "title": "Symphony No 3 In E Flat Major, Op 55 'Eroica' (1803): Marcia Funebre: Adagio Assi", + "artist_credit": [] + }, + { + "duration": 354000, + "title": "Symphony No 3 In E Flat Major, Op 55 'Eroica' (1803): Scherzo And Trio: Allegro Vivace", + "artist_credit": [] + }, + { + "duration": 667000, + "title": "Symphony No 3 In E Flat Major, Op 55 'Eroica' (1803): Finale: Allegro Molto", "artist_credit": [] }, { @@ -18,13 +33,43 @@ { "tracks": [ { - "title": "Symphony No 4 In B Flat Major, Op 60 (1806): Adagio - Allegro Vivace / Adagio / Allegro Vivace / Allegro Ma Non Troppo", - "duration": 1970000, + "duration": 679000, + "title": "Symphony No 4 In B Flat Major, Op 60 (1806): Adagio - Allegro Vivace", + "artist_credit": [] + }, + { + "duration": 546000, + "title": "Symphony No 4 In B Flat Major, Op 60 (1806): Adagio", "artist_credit": [] }, { - "title": "Symphony No 8 In F Major, Op 93 (1812): Allegro Vivace E Con Brio / Allegretto Scherzando / Tempo Di Menuetto / Allegro Vivace", - "duration": 1491000, + "duration": 338000, + "title": "Symphony No 4 In B Flat Major, Op 60 (1806): Allegro Vivace", + "artist_credit": [] + }, + { + "duration": 407000, + "title": "Symphony No 4 In B Flat Major, Op 60 (1806): Allegro Ma Non Troppo", + "artist_credit": [] + }, + { + "duration": 548000, + "title": "Symphony No 8 In F Major, Op 93 (1812): Allegro Vivace E Con Brio", + "artist_credit": [] + }, + { + "duration": 234000, + "title": "Symphony No 8 In F Major, Op 93 (1812): Allegretto Scherzando", + "artist_credit": [] + }, + { + "duration": 264000, + "title": "Symphony No 8 In F Major, Op 93 (1812): Tempo Di Menuetto", + "artist_credit": [] + }, + { + "duration": 445000, + "title": "Symphony No 8 In F Major, Op 93 (1812): Allegro Vivace", "artist_credit": [] } ], @@ -33,13 +78,43 @@ { "tracks": [ { - "title": "Symphony No 5 In C Minor, Op 67 (1807-08): Allegro Con Brio / Andante Con Moto / Allegro / Allegro", - "duration": 1883000, + "duration": 455000, + "title": "Symphony No 5 In C Minor, Op 67 (1807-08): Allegro Con Brio", + "artist_credit": [] + }, + { + "duration": 516000, + "title": "Symphony No 5 In C Minor, Op 67 (1807-08): Andante Con Moto", + "artist_credit": [] + }, + { + "duration": 294000, + "title": "Symphony No 5 In C Minor, Op 67 (1807-08): Allegro", + "artist_credit": [] + }, + { + "duration": 618000, + "title": "Symphony No 5 In C Minor, Op 67 (1807-08): Allegro", + "artist_credit": [] + }, + { + "duration": 580000, + "title": "Symphony No 1 In C Major, Op 21 (1799-1800): Adagio Molto - Allegro Con Brio", + "artist_credit": [] + }, + { + "duration": 412000, + "title": "Symphony No 1 In C Major, Op 21 (1799-1800): Andante Cantabile Con Moto", + "artist_credit": [] + }, + { + "duration": 199000, + "title": "Symphony No 1 In C Major, Op 21 (1799-1800): Menuetto & Trio: Allegro Molto E Vivace", "artist_credit": [] }, { - "title": "Symphony No 1 In C Major, Op 21 (1799-1800): Adagio Molto - Allegro Con Brio / Andante Cantabile Con Moto / Menuetto & Trio: Allegro Molto E Vivace / Adagio - Allegro Molto E Vivace", - "duration": 1537000, + "duration": 346000, + "title": "Symphony No 1 In C Major, Op 21 (1799-1800): Adagio - Allegro Molto E Vivace", "artist_credit": [] } ], @@ -48,13 +123,48 @@ { "tracks": [ { - "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Erwachen Heiterer Gefühle Bei Der Ankunft Auf Dem Lande (Allegro Ma Non Troppo) / Szene Am Bach (Andante Molto Mosso) / Lustiges Zusammensein Der Landleute (Allegro) / Gewitter, Sturm (Allegro) / Hirtengesang - Frohe, Dankbare Gefühle Nach Dem Sturm (Allegretto)", - "duration": 2495000, + "duration": 699000, + "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Erwachen Heiterer Gefühle Bei Der Ankunft Auf Dem Lande (Allegro Ma Non Troppo)", "artist_credit": [] }, { - "title": "Symphony No 2 In D Major, Op 36 (1799-1802): Adagio Molto - Allegro Con Brio / Larghetto / Scherzo & Trio: Allegro / Allegro Molto", - "duration": 2068000, + "duration": 708000, + "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Szene Am Bach (Andante Molto Mosso)", + "artist_credit": [] + }, + { + "duration": 299000, + "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Lustiges Zusammensein Der Landleute (Allegro)", + "artist_credit": [] + }, + { + "duration": 212000, + "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Gewitter, Sturm (Allegro)", + "artist_credit": [] + }, + { + "duration": 577000, + "title": "Symphony No 6 In F Major, Op 68 'Pastoral' (1807-08): Hirtengesang - Frohe, Dankbare Gefühle Nach Dem Sturm (Allegretto)", + "artist_credit": [] + }, + { + "duration": 786000, + "title": "Symphony No 2 In D Major, Op 36 (1799-1802): Adagio Molto - Allegro Con Brio", + "artist_credit": [] + }, + { + "duration": 643000, + "title": "Symphony No 2 In D Major, Op 36 (1799-1802): Larghetto", + "artist_credit": [] + }, + { + "duration": 240000, + "title": "Symphony No 2 In D Major, Op 36 (1799-1802): Scherzo & Trio: Allegro", + "artist_credit": [] + }, + { + "duration": 399000, + "title": "Symphony No 2 In D Major, Op 36 (1799-1802): Allegro Molto", "artist_credit": [] } ], @@ -63,13 +173,38 @@ { "tracks": [ { - "title": "Symphony No 7 In A Major, Op 92 (1811-12): Poco Sostenuto - Vivace / Allegretto / Presto / Allegro Con Brio", - "duration": 2321000, + "duration": 805000, + "title": "Symphony No 7 In A Major, Op 92 (1811-12): Poco Sostenuto - Vivace", "artist_credit": [] }, { - "title": "Triple Concerto In C Major For Piano, Violin And Cello Op 56 (1803-1804): Allegro / Largo / Rondo Alla Polacca", - "duration": 2154000, + "duration": 461000, + "title": "Symphony No 7 In A Major, Op 92 (1811-12): Allegretto", + "artist_credit": [] + }, + { + "duration": 545000, + "title": "Symphony No 7 In A Major, Op 92 (1811-12): Presto", + "artist_credit": [] + }, + { + "duration": 510000, + "title": "Symphony No 7 In A Major, Op 92 (1811-12): Allegro Con Brio", + "artist_credit": [] + }, + { + "duration": 1060000, + "title": "Triple Concerto In C Major For Piano, Violin And Cello Op 56 (1803-1804): Allegro", + "artist_credit": [] + }, + { + "duration": 301000, + "title": "Triple Concerto In C Major For Piano, Violin And Cello Op 56 (1803-1804): Largo", + "artist_credit": [] + }, + { + "duration": 793000, + "title": "Triple Concerto In C Major For Piano, Violin And Cello Op 56 (1803-1804): Rondo Alla Polacca", "artist_credit": [] } ], @@ -78,8 +213,23 @@ { "tracks": [ { - "title": "Symphony No 9 In D Minor, Op 125 'Choral' (1823-24): Allegro Ma Non Troppo, Un Poco Maestoso / Scherzo: Molto Vivace / Adagio Molto E Cantabile / Presto - Allegro Ma Non Troppo - Vivace - Adagio Cantabile", - "duration": 4091000, + "duration": 936000, + "title": "Symphony No 9 In D Minor, Op 125 'Choral' (1823-24): Allegro Ma Non Troppo, Un Poco Maestoso", + "artist_credit": [] + }, + { + "duration": 830000, + "title": "Symphony No 9 In D Minor, Op 125 'Choral' (1823-24): Scherzo: Molto Vivace", + "artist_credit": [] + }, + { + "duration": 852000, + "title": "Symphony No 9 In D Minor, Op 125 'Choral' (1823-24): Adagio Molto E Cantabile", + "artist_credit": [] + }, + { + "duration": 1473000, + "title": "Symphony No 9 In D Minor, Op 125 'Choral' (1823-24): Presto - Allegro Ma Non Troppo - Vivace - Adagio Cantabile", "artist_credit": [] } ], diff --git a/tests/discogs/snapshots/1996829.json b/tests/discogs/snapshots/1996829.json index 41444f1..1125553 100644 --- a/tests/discogs/snapshots/1996829.json +++ b/tests/discogs/snapshots/1996829.json @@ -73,8 +73,23 @@ "artist_credit": [] }, { - "title": "Eine Kleine Nachtmusik, K.525: I. Allegro / II. Romance: Andante / III. Menuetto: Allegretto / IV. Rondo: Allegro", - "duration": 1056000, + "duration": 338000, + "title": "Eine Kleine Nachtmusik, K.525: I. Allegro", + "artist_credit": [] + }, + { + "duration": 362000, + "title": "Eine Kleine Nachtmusik, K.525: II. Romance: Andante", + "artist_credit": [] + }, + { + "duration": 124000, + "title": "Eine Kleine Nachtmusik, K.525: III. Menuetto: Allegretto", + "artist_credit": [] + }, + { + "duration": 232000, + "title": "Eine Kleine Nachtmusik, K.525: IV. Rondo: Allegro", "artist_credit": [] } ], diff --git a/tests/discogs/snapshots/350350.json b/tests/discogs/snapshots/350350.json index 5c761c2..720f521 100644 --- a/tests/discogs/snapshots/350350.json +++ b/tests/discogs/snapshots/350350.json @@ -3,8 +3,55 @@ { "tracks": [ { - "title": "Crashing Aeroplanes: Hindenburg At Lakehurst / Voice Recorder / Value Jet 592 At Miami / To The Sky / Value Jet 592 At Everglades / Case Of Emergency / EIAI 1862 At Amsterdam / Up There / JAL 123 At Mount Osutaka / Autopilot / PanAm 103 At Lockerbie / Last Words / Baggage Claim", - "duration": 3037000, + "title": "Crashing Aeroplanes: Hindenburg At Lakehurst", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Voice Recorder", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Value Jet 592 At Miami", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: To The Sky", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Value Jet 592 At Everglades", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Case Of Emergency", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: EIAI 1862 At Amsterdam", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Up There", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: JAL 123 At Mount Osutaka", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Autopilot", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: PanAm 103 At Lockerbie", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Last Words", + "artist_credit": [] + }, + { + "title": "Crashing Aeroplanes: Baggage Claim", "artist_credit": [] } ], diff --git a/tests/discogs/snapshots/5880212.json b/tests/discogs/snapshots/5880212.json index 1012f61..f1c9b3a 100644 --- a/tests/discogs/snapshots/5880212.json +++ b/tests/discogs/snapshots/5880212.json @@ -3,23 +3,63 @@ { "tracks": [ { - "title": "Harpsichord Concerto In D Minor, BWV 1052: I. Allegro / II. Adagio / III. Allegro", - "duration": 1255000, + "duration": 447000, + "title": "Harpsichord Concerto In D Minor, BWV 1052: I. Allegro", "artist_credit": [] }, { - "title": "Harpsichord Concerto In F Major, BWV 1057: I. [Allegro] / II. Andante / III. Allegro Assai", - "duration": 942000, + "duration": 361000, + "title": "Harpsichord Concerto In D Minor, BWV 1052: II. Adagio", "artist_credit": [] }, { - "title": "Harpsichord Concerto In G Minor, BWV 1058: I. [Allegro] / II. Andante / III. Allegro Assai ", - "duration": 763000, + "duration": 441000, + "title": "Harpsichord Concerto In D Minor, BWV 1052: III. Allegro", "artist_credit": [] }, { - "title": "Harpsichord Concerto In D Major, BWV 1054: I. Allegro / II. Adagio E Piano Sempre / III. Allegro", - "duration": 955000, + "duration": 410000, + "title": "Harpsichord Concerto In F Major, BWV 1057: I. [Allegro]", + "artist_credit": [] + }, + { + "duration": 228000, + "title": "Harpsichord Concerto In F Major, BWV 1057: II. Andante", + "artist_credit": [] + }, + { + "duration": 300000, + "title": "Harpsichord Concerto In F Major, BWV 1057: III. Allegro Assai", + "artist_credit": [] + }, + { + "duration": 204000, + "title": "Harpsichord Concerto In G Minor, BWV 1058: I. [Allegro]", + "artist_credit": [] + }, + { + "duration": 350000, + "title": "Harpsichord Concerto In G Minor, BWV 1058: II. Andante", + "artist_credit": [] + }, + { + "duration": 205000, + "title": "Harpsichord Concerto In G Minor, BWV 1058: III. Allegro Assai ", + "artist_credit": [] + }, + { + "duration": 453000, + "title": "Harpsichord Concerto In D Major, BWV 1054: I. Allegro", + "artist_credit": [] + }, + { + "duration": 331000, + "title": "Harpsichord Concerto In D Major, BWV 1054: II. Adagio E Piano Sempre", + "artist_credit": [] + }, + { + "duration": 166000, + "title": "Harpsichord Concerto In D Major, BWV 1054: III. Allegro", "artist_credit": [] } ], @@ -28,23 +68,63 @@ { "tracks": [ { - "title": "Harpsichord Concerto In E Major, BWV 1053: I. [Allegro] / II. Siciliano / III. Allegro", - "duration": 1216000, + "duration": 467000, + "title": "Harpsichord Concerto In E Major, BWV 1053: I. [Allegro]", + "artist_credit": [] + }, + { + "duration": 323000, + "title": "Harpsichord Concerto In E Major, BWV 1053: II. Siciliano", + "artist_credit": [] + }, + { + "duration": 362000, + "title": "Harpsichord Concerto In E Major, BWV 1053: III. Allegro", + "artist_credit": [] + }, + { + "duration": 189000, + "title": "Harpsichord Concerto In F Minor, BWV 1056: I. [Allegro]", + "artist_credit": [] + }, + { + "duration": 168000, + "title": "Harpsichord Concerto In F Minor, BWV 1056: II. Largo", + "artist_credit": [] + }, + { + "duration": 194000, + "title": "Harpsichord Concerto In F Minor, BWV 1056: III. Presto", + "artist_credit": [] + }, + { + "duration": 252000, + "title": "Harpsichord Concerto In A Major, BWV 1055: I. Allegro", + "artist_credit": [] + }, + { + "duration": 278000, + "title": "Harpsichord Concerto In A Major, BWV 1055: II. Larghetto (Siciliano)", + "artist_credit": [] + }, + { + "duration": 235000, + "title": "Harpsichord Concerto In A Major, BWV 1055: III. Allegro Ma Non Tanto", "artist_credit": [] }, { - "title": "Harpsichord Concerto In F Minor, BWV 1056: I. [Allegro] / II. Largo / III. Presto", - "duration": 554000, + "duration": 513000, + "title": "Concerto For Flute, Violin And Harpsichord In A Minor, BWV 1044: I. Allegro", "artist_credit": [] }, { - "title": "Harpsichord Concerto In A Major, BWV 1055: I. Allegro / II. Larghetto (Siciliano) / III. Allegro Ma Non Tanto", - "duration": 769000, + "duration": 333000, + "title": "Concerto For Flute, Violin And Harpsichord In A Minor, BWV 1044: II. Adagio Ma Non Tanto E Dolce", "artist_credit": [] }, { - "title": "Concerto For Flute, Violin And Harpsichord In A Minor, BWV 1044: I. Allegro / II. Adagio Ma Non Tanto E Dolce / III. Tempo Di Allabreve", - "duration": 1267000, + "duration": 420000, + "title": "Concerto For Flute, Violin And Harpsichord In A Minor, BWV 1044: III. Tempo Di Allabreve", "artist_credit": [] } ], diff --git a/tests/discogs/snapshots/8661943.json b/tests/discogs/snapshots/8661943.json index efb0837..9da6848 100644 --- a/tests/discogs/snapshots/8661943.json +++ b/tests/discogs/snapshots/8661943.json @@ -27,13 +27,55 @@ "number": "A4" }, { - "title": "A Very Strange Medley (V.S.M.): Kentucky Fried Chicken / State Farm Insurance / Stridex / Band-aids / Bowlene / Dr. Pepper / Pepsi / Mc Donalds", - "duration": 370000, + "title": "A Very Strange Medley (V.S.M.): Kentucky Fried Chicken", "artist_credit": [] }, { - "title": "Jump Shout Boogie Medley: Jump Shout Boogie / Avenue C / Jumpin' At The Woodside / Cloudburst / Bandstand Boogie", - "duration": 496000, + "title": "A Very Strange Medley (V.S.M.): State Farm Insurance", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Stridex", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Band-aids", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Bowlene", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Dr. Pepper", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Pepsi", + "artist_credit": [] + }, + { + "title": "A Very Strange Medley (V.S.M.): Mc Donalds", + "artist_credit": [] + }, + { + "title": "Jump Shout Boogie Medley: Jump Shout Boogie", + "artist_credit": [] + }, + { + "title": "Jump Shout Boogie Medley: Avenue C", + "artist_credit": [] + }, + { + "title": "Jump Shout Boogie Medley: Jumpin' At The Woodside", + "artist_credit": [] + }, + { + "title": "Jump Shout Boogie Medley: Cloudburst", + "artist_credit": [] + }, + { + "title": "Jump Shout Boogie Medley: Bandstand Boogie", "artist_credit": [] }, {