Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion batch-add-recording-relationships.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ function batch_recording_rels(gm_info) {
);
}

let $reload = style_buttons($('<button>Reload</button>'))
style_buttons($('<button>Reload</button>'))
.click(function () {
$button_cell.css('display', 'none');
$msg.text(`Loading works for ${name}...`);
Expand Down
1 change: 1 addition & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Logger
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// eslint-disable-next-line no-unused-vars
const LOGGER = (function () {
let LOG_LEVEL = 'info';

Expand Down
1 change: 1 addition & 0 deletions lib/mbimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
*
*/

// eslint-disable-next-line no-unused-vars
const MBImport = (function () {
// --------------------------------------- publics ----------------------------------------- //

Expand Down
2 changes: 2 additions & 0 deletions lib/mbimportstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function _add_css(css) {
document.head.insertAdjacentHTML('beforeend', `<style>${css.replace(/\s+/g, ' ')}</style>`);
}

// eslint-disable-next-line no-unused-vars
function MBImportStyle() {
let css_import_button = `
#mb_buttons {
Expand Down Expand Up @@ -42,6 +43,7 @@ function MBImportStyle() {
_add_css(css_import_button);
}

// eslint-disable-next-line no-unused-vars
function MBSearchItStyle() {
let css_search_it = `
.mb_valign {
Expand Down
3 changes: 2 additions & 1 deletion lib/mblinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// user_cache_key = textual key used to store cached data in local storage
// version = optionnal version, to force creation of a cache (ie. when format of keys changes)
// expiration = time in minutes before an entry is refreshed, value <= 0 disables cache reads, if undefined or false, use defaults
// eslint-disable-next-line no-unused-vars
const MBLinks = function (user_cache_key, version, expiration) {
/**
* Processes a URL match from the MusicBrainz API response: updates cache and inserts
Expand Down Expand Up @@ -71,7 +72,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
this.supports_local_storage = (function () {
try {
return !!localStorage.getItem;
} catch (e) {
} catch {
return false;
}
})();
Expand Down
2 changes: 2 additions & 0 deletions mb_discids_detector.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// @require lib/logger.js
// ==/UserScript==

/* eslint-disable */

console.warn(
'[Musicbrainz DiscIds Detector]: ⚠️ This userscript has been rewritten in TypeScript and is now hosted at a new URL. It should auto-update to use the TS version automatically, but if it didn’t and you’re seeing this message, please upgrade it manually from https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/dist/mb_discids_detector.user.js.',
);
Expand Down
1 change: 0 additions & 1 deletion qobuz_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// @namespace https://github.com/murdos/musicbrainz-userscripts
// @downloadURL https://raw.github.com/murdos/musicbrainz-userscripts/master/qobuz_importer.user.js
// @updateURL https://raw.github.com/murdos/musicbrainz-userscripts/master/qobuz_importer.user.js
// @include /^https?://www\.qobuz\.com/[^/]+/(album|interpreter|label)(/[^/?]+)+(\?.*)?$/

Check warning on line 8 in qobuz_importer.user.js

View workflow job for this annotation

GitHub Actions / lint checks

Using @include is potentially unsafe and may be obsolete in Manifest v3. Please switch to @match
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require lib/mbimport.js?version=v2026.05.30.1
// @require lib/logger.js
Expand All @@ -31,7 +31,6 @@

let is_classical = false; // release detected as classical
let album_artist_data = {}; // for switching album artists on classical
let raw_release_data;

function getOpenQobuzArtistUrl(artistId) {
return `${OPEN_QOBUZ_BASE}/artist/${artistId}`;
Expand Down
91 changes: 16 additions & 75 deletions takealot_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ if (DEBUG) {

// promise to ensure all api calls are done before we parse the release
const tracks_deferred = $.Deferred();
const retrieve_tracks_promise = tracks_deferred.promise();
tracks_deferred.promise();

// object to store all global attributes collected for the release
const release_attributes = {}; // albumid, total_pages, artist_name, label

// arrays to store the data retrieved from API to parse for MB release
const album_api_array = []; // album information [0]
const tracks_api_array = []; // track information [0,1,2,..] one element for each pagination in FMA tracks API

$(document).ready(function () {
LOGGER.info('Document Ready & Takealot Userscript Executing');
Expand All @@ -65,9 +64,8 @@ $(document).ready(function () {
$.when(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);
let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0]);
insertMBSection(FreeMusicArchiveRelease);

let album_link = window.location.href;
Expand Down Expand Up @@ -143,7 +141,7 @@ const updateAPISection = {
},
ApiKey: function (apikey) {
this.apikey = apikey;
$('#lbut-lt-fma-api-key-id').text(FMA_API);
$('#lbut-lt-fma-api-key-id').text(`FMA_API: ${this.apikey}`);
return 'complete';
},
AlbumAjaxStatus: function (ajaxstatus) {
Expand Down Expand Up @@ -301,45 +299,6 @@ function insertMBSection(release) {
mbUI.slideDown();
}

// Insert MusicBrainz API section on FMA page to enter API Key
function insertAPIKEYSection() {
LOGGER.debug('FMA insertAPIKEYSection Function Executing');

let mbUI = $(
'<div id="musicbrainz_apikey" class="section musicbrainz"><h4 class="wlinepad"><span class="hd">Import FMA API KEY for MusicBrainz</span></h4></div>',
).hide();
if (DEBUG)
mbUI.css({
border: '1px dotted red',
});

let mbContentBlock = $('<div class="section_content"></div>');
mbUI.append(mbContentBlock);

// Build section
let innerHTML =
'<span class="mhd-nosep">Please enter API Key found <a class="donate" href="https://freemusicarchive.org/member/api_key" target="_blank">here</a></span>';
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>`;
mbContentBlock.append(innerHTML);

insertMbUI(mbUI); // Insert the MusicBrainzUI

$('#musicbrainz_apikey').css({
display: 'block',
float: 'right',
height: '120px',
width: '49%',
});

$('#mb_buttons').css({
display: 'inline-block',
float: 'right',
height: '80px',
});

mbUI.slideDown();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Retrieve data from TAL API //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -389,23 +348,23 @@ function parseFMApage() {

if (typeof $('#idProduct').attr('value') === 'undefined' && $('div.cell:nth-child(3) > a:nth-child(1)').length) {
LOGGER.debug('Uhm I think the idProduct is missing folks and comments left ...');
let FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href');
const FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href');
LOGGER.debug('The album id for API: ', FMAEmbedCode);
FMAEmbedCodeRegex = /product_id=(\d*)/;
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
const FMAEmbedCodeRegex = /product_id=(\d*)/;
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable
} else if (typeof $('#idProduct').attr('value') === 'undefined' && $('.reviews > a:nth-child(1)').length) {
LOGGER.debug('Uhm I think the idProduct is missing folks ...');
let FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href');
const FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href');
LOGGER.debug('The album id for API: ', FMAEmbedCode);
FMAEmbedCodeRegex = /product_id=(\d*)/;
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
const FMAEmbedCodeRegex = /product_id=(\d*)/;
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable
} else {
LOGGER.debug('Aha got that idProduct value, Jipeeeee ...');
let FMAEmbedCode = $('#idProduct').attr('value');
FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
const FMAEmbedCode = $('#idProduct').attr('value');
const FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
release_attributes.albumid = FMAAlbumIdMatch[0]; // assign the ID to a variable
}

Expand Down Expand Up @@ -440,23 +399,6 @@ function parseFMApage() {
// Analyze FMA data and return a release object //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Parse the date string and set object properties day, month, year
function parse_MM_DD_YYYY(date, obj) {
if (!date) return;
let m = date.split(/\D+/, 3).map(function (e) {
return parseInt(e, 10);
});
if (m[0] !== undefined) {
obj.month = m[0];
if (m[1] !== undefined) {
obj.day = m[1];
if (m[2] !== undefined) {
obj.year = m[2];
}
}
}
}

function parse_YYYY_MM_DD(date, obj) {
if (!date) return;
let m = date.split(/\D+/, 3).map(function (e) {
Expand All @@ -474,7 +416,7 @@ function parse_YYYY_MM_DD(date, obj) {
}

// parse the release from the album and track objects
function Parsefmarelease(albumobject, trackobject) {
function Parsefmarelease(albumobject) {
if (albumobject === undefined) {
albumobject = [];
}
Expand Down Expand Up @@ -704,7 +646,7 @@ function Parsefmarelease(albumobject, trackobject) {
//var lines = alltracklist.val().split('\n');
let lines = alltracklist.split(/\r?\n/);

takealot_format = 'v2_type1';
const takealot_format = 'v2_type1';

// Tracks
let tracklistarray = new Array(); // create the track list array
Expand All @@ -718,15 +660,14 @@ function Parsefmarelease(albumobject, trackobject) {
//let trackdetails = lines[j];
// sample: [ Disc 01 Track 01 ] What Do You Mean? - Justin Bieber
// do this up in regex tester now...
//disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/;
//let disctracktitle = trackdetails.match(disctracktitleregex);
const disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/;
const disctracktitle = lines[j].match(disctracktitleregex);

let currentdiscnumber = 1;
lastdiscnumber = 1;

if (currentdiscnumber == 1) {
let track = {};
let track_artist_credit = [];

track.number = j + 1;
track.title = lines[j];
Expand Down
Loading