{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"assets","path":"assets","contentType":"directory"},{"name":"lib","path":"lib","contentType":"directory"},{"name":"tools","path":"tools","contentType":"directory"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".eslintrc.js","path":".eslintrc.js","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".prettierignore","path":".prettierignore","contentType":"file"},{"name":".prettierrc.json","path":".prettierrc.json","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"bandcamp_importer.user.js","path":"bandcamp_importer.user.js","contentType":"file"},{"name":"bandcamp_importer_helper.user.js","path":"bandcamp_importer_helper.user.js","contentType":"file"},{"name":"batch-add-recording-relationships.user.js","path":"batch-add-recording-relationships.user.js","contentType":"file"},{"name":"beatport_classic_importer.user.js","path":"beatport_classic_importer.user.js","contentType":"file"},{"name":"beatport_importer.user.js","path":"beatport_importer.user.js","contentType":"file"},{"name":"boomkat_importer.user.js","path":"boomkat_importer.user.js","contentType":"file"},{"name":"cd1d_importer.user.js","path":"cd1d_importer.user.js","contentType":"file"},{"name":"deezer_importer.user.js","path":"deezer_importer.user.js","contentType":"file"},{"name":"discogs_importer.user.js","path":"discogs_importer.user.js","contentType":"file"},{"name":"edit-instrument-recordings-links.user.js","path":"edit-instrument-recordings-links.user.js","contentType":"file"},{"name":"encyclopedisque_importer.user.js","path":"encyclopedisque_importer.user.js","contentType":"file"},{"name":"expand-collapse-release-groups.user.js","path":"expand-collapse-release-groups.user.js","contentType":"file"},{"name":"fast-cancel-edits.user.js","path":"fast-cancel-edits.user.js","contentType":"file"},{"name":"fma_importer.user.js","path":"fma_importer.user.js","contentType":"file"},{"name":"hdtracks_importer.user.js","path":"hdtracks_importer.user.js","contentType":"file"},{"name":"juno_download_importer.user.js","path":"juno_download_importer.user.js","contentType":"file"},{"name":"loot_importer.user.js","path":"loot_importer.user.js","contentType":"file"},{"name":"mb_1200px_caa.user.js","path":"mb_1200px_caa.user.js","contentType":"file"},{"name":"mb_discids_detector.user.js","path":"mb_discids_detector.user.js","contentType":"file"},{"name":"mb_relationship_shortcuts.user.js","path":"mb_relationship_shortcuts.user.js","contentType":"file"},{"name":"mb_ui_enhancements.user.js","path":"mb_ui_enhancements.user.js","contentType":"file"},{"name":"metalarchives_importer.user.js","path":"metalarchives_importer.user.js","contentType":"file"},{"name":"naxos_library3_importer.user.js","path":"naxos_library3_importer.user.js","contentType":"file"},{"name":"naxos_library_importer.user.js","path":"naxos_library_importer.user.js","contentType":"file"},{"name":"package-lock.json","path":"package-lock.json","contentType":"file"},{"name":"package.json","path":"package.json","contentType":"file"},{"name":"qobuz_importer.user.js","path":"qobuz_importer.user.js","contentType":"file"},{"name":"set-recording-comments.user.js","path":"set-recording-comments.user.js","contentType":"file"},{"name":"takealot_importer.user.js","path":"takealot_importer.user.js","contentType":"file"},{"name":"vgmdb_importer.user.js","path":"vgmdb_importer.user.js","contentType":"file"}],"totalCount":40}},"fileTreeProcessingTime":5.097459000000001,"foldersToFetch":[],"repo":{"id":3710200,"defaultBranch":"master","name":"musicbrainz-userscripts","ownerLogin":"murdos","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2012-03-13T19:08:59.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/155828?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1678114609.539447","canEdit":false,"refType":"branch","currentOid":"df7c9a4a233de63fe8d9a52a8a715f3c6c22a0a9"},"path":"fma_importer.user.js","currentUser":null,"blob":{"rawLines":["// ==UserScript==","// @name Import FMA releases to MusicBrainz","// @description Add a button to import https://freemusicarchive.org/ releases to MusicBrainz via API","// @version 2018.2.18.1","// @namespace https://github.com/murdos/musicbrainz-userscripts","// @downloadURL https://raw.github.com/murdos/musicbrainz-userscripts/master/fma_importer.user.js","// @updateURL https://raw.github.com/murdos/musicbrainz-userscripts/master/fma_importer.user.js","// @include http*://freemusicarchive.org/music/*","// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js","// @require lib/mbimport.js","// @require lib/logger.js","// @require lib/mblinks.js","// @require lib/mbimportstyle.js","// @icon https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/assets/images/Musicbrainz_import_logo.png","// @grant none","// ==/UserScript==","","/*"," * Test cases:"," * http://freemusicarchive.org/music/Various_Artists/Of_Men_And_Machines/"," * http://freemusicarchive.org/music/cloud_mouth/songs_from_the_sewer/"," * http://freemusicarchive.org/music/Podington_Bear/Springtime/"," * http://freemusicarchive.org/music/Broke_For_Free/Directionless_EP/"," * http://freemusicarchive.org/music/Various_Artists_Evergreens_n_Odditunes/Evergreens_n_Odditunes/"," * Radio program: http://freemusicarchive.org/music/Kyle_Eyre_Clyd/Live_on_WFMUs_Strength_Through_Failure_with_Fabio_Roberti_8132015/"," */","","// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant","this.$ = this.jQuery = jQuery.noConflict(true);","","// API Key assigned to registered user on FMA","var FMA_API = 'FMA API KEY Missing';","","var DEBUG = false; // true | false","","if (DEBUG) {"," LOGGER.setLevel('debug');","}","","// promise to ensure all api calls are done before we parse the release","var tracks_deferred = $.Deferred();","var retrieve_tracks_promise = tracks_deferred.promise();","","// object to store all global attributes collected for the release","var release_attributes = {}; // albumid, total_pages, artist_name, label","","// arrays to store the data retrieved from API to parse for MB release","var album_api_array = []; // album information [0]","var tracks_api_array = []; // track information [0,1,2,..] one element for each pagination in FMA tracks API","","$(document).ready(function () {"," // if we have something on local storage place that"," if (localStorage.getItem('FMA_API_KEY')) {"," FMA_API = localStorage.getItem('FMA_API_KEY'); // -> YOURAPIKEY"," } else {"," insertAPIKEYSection();"," $('#api_key_submit').click(function () {"," let myval = $('#apikey_input').val();"," localStorage.setItem('FMA_API_KEY', myval);"," $('#musicbrainz_apikey').hide();"," FMA_API = localStorage.getItem('FMA_API_KEY'); // -> YOURAPIKEY"," LOGGER.debug(`FMA API Key set: ${FMA_API}`);"," location.reload(true); //as document loaded and FMA_API was set out of scope"," });"," }",""," // window.localStorage.clear() hint: to clear the localStorage if needed",""," LOGGER.info('Document Ready & FMA Userscript Executing');",""," let fmaPage = parseFMApage();"," let mblinks = new MBLinks('FMA_CACHE', 7 * 24 * 60);",""," if (DEBUG) {"," insertAPISection();"," updateAPISection.AlbumId(release_attributes.albumid);"," updateAPISection.ApiKey(FMA_API);"," }",""," if ($('.minitag-album').length && FMA_API !== 'FMA API KEY Missing') {"," // To make sure API and release only build on Album page.",""," // Track parameters: total number of pages / api calls limit hardcoded to max of 20"," let retrieve_track_info = new track_api_parameters();"," // Album detail"," let retrieve_album_detail = new album_api();",""," // Track detail"," $.when(retrieve_track_info) // ensure the track info is retrieved first (total_pages counter)"," .then(function () {"," // loop and deferred promise for multiple ajax calls"," updateAPISection.TrackAjaxStatus('busy');"," let track_api_calls = [];"," for (let i = 1; i <= release_attributes.total_pages; i++) {"," track_api_calls.push(track_api(i));"," }",""," $.when.apply(this, track_api_calls).done(function () {"," LOGGER.debug('Tracks loaded and done in DONE lets use it');"," //console.log(\"total_pages \" + release_attributes.total_pages);"," tracks_deferred.resolve();"," });"," })"," .done(function () {"," LOGGER.debug('Deferred for: Track info > track detail > resolved');"," });",""," $.when(retrieve_tracks_promise)"," .done(function () {"," updateAPISection.TrackAjaxStatus('completed');"," })"," .fail(function () {"," updateAPISection.TrackAjaxStatus('fail');"," });",""," $.when(retrieve_track_info, retrieve_tracks_promise, retrieve_album_detail).done(function () {"," LOGGER.info('All the AJAX API calls are done continue to build the release object ...');"," // LOGGER.debug(\"ALBUM Object > \" + album_api_array[0]);"," // LOGGER.debug(\"TRACK Object > \" + tracks_api_array);",""," let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0], tracks_api_array);"," insertMBSection(FreeMusicArchiveRelease);",""," let album_link = window.location.href;",""," let url = $(location).attr('href').split('/');"," let artist_url = url[url.length - 3];"," let base_url = 'http://freemusicarchive.org/music/';"," let artist_link = `${base_url + artist_url}/`;",""," mblinks.searchAndDisplayMbLink(album_link, 'release', function (link) {"," $('.subh1').before(link);"," });"," mblinks.searchAndDisplayMbLink(artist_link, 'artist', function (link) {"," $('.subh1').after(link);"," });"," });"," }","});","","// Determine the location on page to add MusicBrainz Section","function insertMbUI(mbUI) {"," let e;"," if ((e = $('#header')) && e.length) {"," e.after(mbUI);"," } else if ((e = $('#content')) && e.length) {"," e.before(mbUI);"," } else if ((e = $('.brumbs')) && e.length) {"," e.append(mbUI);"," }","}","","// Insert link to high resolution image on FMA page","function insertIMGlinks() {"," //LOGGER.debug(\"FMA insertIMGlinks Function Executing\");"," let imgsrc = $('#image-1 img.sbar-fullimg').attr('src');"," imgsrc = imgsrc.substring(0, imgsrc.indexOf('?'));"," //LOGGER.debug(\" insertIMGlinks > imgsrc:\", imgsrc);"," $('#album-images').append(`
`);","}","","// Insert FreeMusicArchive API Status section on FMA page","function insertAPISection() {"," //LOGGER.debug(\"FMA insertAPISection Function Executing\");",""," let fmaUI = $(' ').hide();",""," if (DEBUG)"," fmaUI.css({"," border: '1px dotted red',"," });",""," let fmaStatusBlock = $("," '» » Album info retrievedTrack info retrieved'"," );"," fmaUI.append(fmaStatusBlock);",""," insertMbUI(fmaUI); // Insert the FMA API Status UI",""," $('#fmaapistatus').css({"," display: 'inline-block',"," float: 'left',"," height: '120px',"," width: '49%',"," });",""," fmaUI.slideDown();","}","","// Update FreeMusicArchive API Status section on FMA page","var updateAPISection = {"," AlbumId: function (albumid) {"," this.albumid = albumid;"," $('#lbut-lt-fma-api-album-id').text(this.albumid);"," return 'complete';"," },"," ApiKey: function (apikey) {"," this.apikey = apikey;"," $('#lbut-lt-fma-api-key-id').text(FMA_API);"," return 'complete';"," },"," AlbumAjaxStatus: function (ajaxstatus) {"," if (ajaxstatus === null) {"," this.ajaxstatus = 'notcalled';"," } else {"," this.ajaxstatus = ajaxstatus;"," }",""," switch (this.ajaxstatus) {"," case 'completed': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-album').css({"," 'background-color': 'green',"," });"," break;"," case 'busy': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-album').css({"," 'background-color': 'orange',"," });"," break;"," case 'fail': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-album').css({"," 'background-color': 'red',"," });"," break;"," }"," },"," TrackAjaxStatus: function (ajaxstatus) {"," if (ajaxstatus === null) {"," this.ajaxstatus = 'notcalled';"," } else {"," this.ajaxstatus = ajaxstatus;"," }",""," switch (this.ajaxstatus) {"," case 'completed': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-tracks').css({"," 'background-color': 'green',"," });"," break;"," case 'busy': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-tracks').css({"," 'background-color': 'orange',"," });"," break;"," case 'fail': // Definition is that api call was successfull hence busy retrieving data"," //test chaging status of album api to error retrieving data after 2 seconds"," $('#lbut-lt-fma-api-tracks').css({"," 'background-color': 'red',"," });"," break;"," }"," },","};","","// Insert MusicBrainz section on FMA page","function insertMBSection(release) {"," //LOGGER.debug(release);",""," let mbUI = $("," 'Warning: this release is buggy, please check twice the data you import.
${MBImport.buildFormHTML(parameters)}${MBImport.buildSearchButton(release)}`;"," mbContentBlock.append(innerHTML);",""," insertMbUI(mbUI); // Insert the MusicBrainzUI"," insertIMGlinks(); // Insert the link to high res image",""," $('#musicbrainz').css({"," display: 'block',"," float: 'right',"," height: '120px',"," width: '49%',"," });",""," $('#mb_buttons').css({"," display: 'inline-block',"," float: 'right',"," height: '80px',"," });"," $('form.musicbrainz_import').css({"," width: '49%',"," display: 'inline-block',"," });"," $('form.musicbrainz_import_search').css({"," float: 'right',"," });"," $('form.musicbrainz_import > button').css({"," width: '63px',"," height: '80px',"," 'box-sizing': 'border-box',"," });",""," mbUI.slideDown();","}","","// Insert MusicBrainz API section on FMA page to enter API Key","function insertAPIKEYSection() {"," LOGGER.debug('FMA insertAPIKEYSection Function Executing');",""," let mbUI = $("," '