@@ -36,14 +36,13 @@ if (DEBUG) {
3636
3737// promise to ensure all api calls are done before we parse the release
3838const tracks_deferred = $ . Deferred ( ) ;
39- const retrieve_tracks_promise = tracks_deferred . promise ( ) ;
39+ tracks_deferred . promise ( ) ;
4040
4141// object to store all global attributes collected for the release
4242const release_attributes = { } ; // albumid, total_pages, artist_name, label
4343
4444// arrays to store the data retrieved from API to parse for MB release
4545const album_api_array = [ ] ; // album information [0]
46- const tracks_api_array = [ ] ; // track information [0,1,2,..] one element for each pagination in FMA tracks API
4746
4847$ ( document ) . ready ( function ( ) {
4948 LOGGER . info ( 'Document Ready & Takealot Userscript Executing' ) ;
@@ -65,9 +64,8 @@ $(document).ready(function () {
6564 $ . when ( retrieve_album_detail ) . done ( function ( ) {
6665 LOGGER . info ( 'All the AJAX API calls are done continue to build the release object ...' ) ;
6766 LOGGER . debug ( `ALBUM Object > ${ album_api_array [ 0 ] } ` ) ;
68- // LOGGER.debug("TRACK Object > " + tracks_api_array);
6967
70- let FreeMusicArchiveRelease = new Parsefmarelease ( album_api_array [ 0 ] , tracks_api_array ) ;
68+ let FreeMusicArchiveRelease = new Parsefmarelease ( album_api_array [ 0 ] ) ;
7169 insertMBSection ( FreeMusicArchiveRelease ) ;
7270
7371 let album_link = window . location . href ;
@@ -143,7 +141,7 @@ const updateAPISection = {
143141 } ,
144142 ApiKey : function ( apikey ) {
145143 this . apikey = apikey ;
146- $ ( '#lbut-lt-fma-api-key-id' ) . text ( FMA_API ) ;
144+ $ ( '#lbut-lt-fma-api-key-id' ) . text ( ` FMA_API: ${ this . apikey } ` ) ;
147145 return 'complete' ;
148146 } ,
149147 AlbumAjaxStatus : function ( ajaxstatus ) {
@@ -301,45 +299,6 @@ function insertMBSection(release) {
301299 mbUI . slideDown ( ) ;
302300}
303301
304- // Insert MusicBrainz API section on FMA page to enter API Key
305- function insertAPIKEYSection ( ) {
306- LOGGER . debug ( 'FMA insertAPIKEYSection Function Executing' ) ;
307-
308- let mbUI = $ (
309- '<div id="musicbrainz_apikey" class="section musicbrainz"><h4 class="wlinepad"><span class="hd">Import FMA API KEY for MusicBrainz</span></h4></div>' ,
310- ) . hide ( ) ;
311- if ( DEBUG )
312- mbUI . css ( {
313- border : '1px dotted red' ,
314- } ) ;
315-
316- let mbContentBlock = $ ( '<div class="section_content"></div>' ) ;
317- mbUI . append ( mbContentBlock ) ;
318-
319- // Build section
320- let innerHTML =
321- '<span class="mhd-nosep">Please enter API Key found <a class="donate" href="https://freemusicarchive.org/member/api_key" target="_blank">here</a></span>' ;
322- innerHTML = `${ innerHTML } <div id="mb_buttons"><input id="apikey_input" type="text" name="apikey_input" value=""><br><input id="api_key_submit" type="submit" value="Import API KEY"></div>` ;
323- mbContentBlock . append ( innerHTML ) ;
324-
325- insertMbUI ( mbUI ) ; // Insert the MusicBrainzUI
326-
327- $ ( '#musicbrainz_apikey' ) . css ( {
328- display : 'block' ,
329- float : 'right' ,
330- height : '120px' ,
331- width : '49%' ,
332- } ) ;
333-
334- $ ( '#mb_buttons' ) . css ( {
335- display : 'inline-block' ,
336- float : 'right' ,
337- height : '80px' ,
338- } ) ;
339-
340- mbUI . slideDown ( ) ;
341- }
342-
343302////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
344303// Retrieve data from TAL API //
345304////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -389,23 +348,23 @@ function parseFMApage() {
389348
390349 if ( typeof $ ( '#idProduct' ) . attr ( 'value' ) === 'undefined' && $ ( 'div.cell:nth-child(3) > a:nth-child(1)' ) . length ) {
391350 LOGGER . debug ( 'Uhm I think the idProduct is missing folks and comments left ...' ) ;
392- let FMAEmbedCode = $ ( 'div.cell:nth-child(3) > a:nth-child(1)' ) . attr ( 'href' ) ;
351+ const FMAEmbedCode = $ ( 'div.cell:nth-child(3) > a:nth-child(1)' ) . attr ( 'href' ) ;
393352 LOGGER . debug ( 'The album id for API: ' , FMAEmbedCode ) ;
394- FMAEmbedCodeRegex = / p r o d u c t _ i d = ( \d * ) / ;
395- let FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
353+ const FMAEmbedCodeRegex = / p r o d u c t _ i d = ( \d * ) / ;
354+ const FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
396355 release_attributes . albumid = FMAAlbumIdMatch [ 1 ] ; // assign the ID to a variable
397356 } else if ( typeof $ ( '#idProduct' ) . attr ( 'value' ) === 'undefined' && $ ( '.reviews > a:nth-child(1)' ) . length ) {
398357 LOGGER . debug ( 'Uhm I think the idProduct is missing folks ...' ) ;
399- let FMAEmbedCode = $ ( '.reviews > a:nth-child(1)' ) . attr ( 'href' ) ;
358+ const FMAEmbedCode = $ ( '.reviews > a:nth-child(1)' ) . attr ( 'href' ) ;
400359 LOGGER . debug ( 'The album id for API: ' , FMAEmbedCode ) ;
401- FMAEmbedCodeRegex = / p r o d u c t _ i d = ( \d * ) / ;
402- let FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
360+ const FMAEmbedCodeRegex = / p r o d u c t _ i d = ( \d * ) / ;
361+ const FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
403362 release_attributes . albumid = FMAAlbumIdMatch [ 1 ] ; // assign the ID to a variable
404363 } else {
405364 LOGGER . debug ( 'Aha got that idProduct value, Jipeeeee ...' ) ;
406- let FMAEmbedCode = $ ( '#idProduct' ) . attr ( 'value' ) ;
407- FMAEmbedCodeRegex = / \d { 8 } / ; // regex to match the value from the idProduct object
408- let FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
365+ const FMAEmbedCode = $ ( '#idProduct' ) . attr ( 'value' ) ;
366+ const FMAEmbedCodeRegex = / \d { 8 } / ; // regex to match the value from the idProduct object
367+ const FMAAlbumIdMatch = FMAEmbedCode . match ( FMAEmbedCodeRegex ) ; // match the Id
409368 release_attributes . albumid = FMAAlbumIdMatch [ 0 ] ; // assign the ID to a variable
410369 }
411370
@@ -440,23 +399,6 @@ function parseFMApage() {
440399// Analyze FMA data and return a release object //
441400////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
442401
443- // Parse the date string and set object properties day, month, year
444- function parse_MM_DD_YYYY ( date , obj ) {
445- if ( ! date ) return ;
446- let m = date . split ( / \D + / , 3 ) . map ( function ( e ) {
447- return parseInt ( e , 10 ) ;
448- } ) ;
449- if ( m [ 0 ] !== undefined ) {
450- obj . month = m [ 0 ] ;
451- if ( m [ 1 ] !== undefined ) {
452- obj . day = m [ 1 ] ;
453- if ( m [ 2 ] !== undefined ) {
454- obj . year = m [ 2 ] ;
455- }
456- }
457- }
458- }
459-
460402function parse_YYYY_MM_DD ( date , obj ) {
461403 if ( ! date ) return ;
462404 let m = date . split ( / \D + / , 3 ) . map ( function ( e ) {
@@ -474,7 +416,7 @@ function parse_YYYY_MM_DD(date, obj) {
474416}
475417
476418// parse the release from the album and track objects
477- function Parsefmarelease ( albumobject , trackobject ) {
419+ function Parsefmarelease ( albumobject ) {
478420 if ( albumobject === undefined ) {
479421 albumobject = [ ] ;
480422 }
@@ -704,7 +646,7 @@ function Parsefmarelease(albumobject, trackobject) {
704646 //var lines = alltracklist.val().split('\n');
705647 let lines = alltracklist . split ( / \r ? \n / ) ;
706648
707- takealot_format = 'v2_type1' ;
649+ const takealot_format = 'v2_type1' ;
708650
709651 // Tracks
710652 let tracklistarray = new Array ( ) ; // create the track list array
@@ -718,15 +660,14 @@ function Parsefmarelease(albumobject, trackobject) {
718660 //let trackdetails = lines[j];
719661 // sample: [ Disc 01 Track 01 ] What Do You Mean? - Justin Bieber
720662 // do this up in regex tester now...
721- // disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/;
722- //let disctracktitle = trackdetails .match(disctracktitleregex);
663+ const disctracktitleregex = / \[ D i s c ( \d { 2 } ) T r a c k .( \b \d { 2 } ) \] ( .* ) - ( .* ) / ;
664+ const disctracktitle = lines [ j ] . match ( disctracktitleregex ) ;
723665
724666 let currentdiscnumber = 1 ;
725667 lastdiscnumber = 1 ;
726668
727669 if ( currentdiscnumber == 1 ) {
728670 let track = { } ;
729- let track_artist_credit = [ ] ;
730671
731672 track . number = j + 1 ;
732673 track . title = lines [ j ] ;
0 commit comments