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 @@
);
}

let $reload = style_buttons($('<button>Reload</button>'))

Check warning on line 733 in batch-add-recording-relationships.user.js

View workflow job for this annotation

GitHub Actions / lint checks

'$reload' is assigned a value but never used
.click(function () {
$button_cell.css('display', 'none');
$msg.text(`Loading works for ${name}...`);
Expand Down Expand Up @@ -807,7 +807,7 @@
}

function request_works(url, offset, count, callback) {
$.get(`${url}&offset=${offset}`, function (data, textStatus, jqXHR) {
$.get(`${url}&offset=${offset}`, function (data) {
if (count < 0) {
count = data['work-count'];
}
Expand Down
2 changes: 1 addition & 1 deletion beatport_classic_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
this.$ = this.jQuery = jQuery.noConflict(true);

if (!unsafeWindow) unsafeWindow = window;

Check warning on line 19 in beatport_classic_importer.user.js

View workflow job for this annotation

GitHub Actions / lint checks

Read-only global 'unsafeWindow' should not be modified

$(document).ready(function () {
MBImportStyle();
Expand All @@ -28,7 +28,7 @@

function retrieveReleaseInfo(release_url) {
function contains_or(selector, list) {
selectors = [];
const selectors = [];
$.each(list, function (ind, value) {
selectors.push(`${selector}:contains("${value.replace('"', '\\"')}")`);
});
Expand Down
8 changes: 4 additions & 4 deletions cd1d_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CD1DImporter = {
};
});
// remove "parent" formats : ie. digital when mp3 and flac are present
for (var i = 0; i < formats.length; i++) {
for (let i = 0; i < formats.length; i++) {
for (let j = i + 1; j < formats.length; j++) {
if (formats[j].id.length > 1) {
if (formats[i].id[1] == formats[j].id[1]) {
Expand All @@ -48,7 +48,7 @@ const CD1DImporter = {
}
}
let cleanformats = [];
for (var i = 0; i < formats.length; i++) {
for (let i = 0; i < formats.length; i++) {
if (!formats[i].toremove) {
cleanformats.push({
id: formats[i].id.join('-'),
Expand All @@ -64,7 +64,7 @@ const CD1DImporter = {
let tracklists = `div#${id} div.tracklist table.tracklist-content`;
let discs = [];
$(tracklists).each(function () {
disc = $(this)
const disc = $(this)
.find('tbody tr')
.map(function () {
// $(this) is used more than once; cache it for performance.
Expand Down Expand Up @@ -225,7 +225,7 @@ const CD1DImporter = {
.get();

// Tracks
$.each(this.getTracks(format.id), function (ndisc, disc) {
$.each(this.getTracks(format.id), function () {
let thisdisc = {
tracks: [],
format: release.format,
Expand Down
2 changes: 1 addition & 1 deletion fast-cancel-edits.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function fastCancelScript() {
}
});

var pushRequest = (function () {
const pushRequest = (function () {
let queue = [],
last = 0,
active = false,
Expand Down
19 changes: 9 additions & 10 deletions fma_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
}

// Update FreeMusicArchive API Status section on FMA page
var updateAPISection = {
const updateAPISection = {
AlbumId: function (albumid) {
this.albumid = albumid;
$('#lbut-lt-fma-api-album-id').text(this.albumid);
Expand Down Expand Up @@ -369,7 +369,7 @@
function album_api() {
let fmaWsUrl = `https://freemusicarchive.org/api/get/albums.json?api_key=${FMA_API}&album_id=${release_attributes.albumid}`;

var promise_variable = $.getJSON(fmaWsUrl, function () {
const promise_variable = $.getJSON(fmaWsUrl, function () {
updateAPISection.AlbumAjaxStatus('busy');
LOGGER.debug(`promise_variable [state] in [getJSON] ${promise_variable.state()}`);
}).done(function (albumjson) {
Expand All @@ -387,7 +387,7 @@
function track_api_parameters() {
let fmaWsUrl = `https://freemusicarchive.org/api/get/tracks.json?api_key=${FMA_API}&album_id=${release_attributes.albumid}&limit=20`;

var promise_track_api_params = $.getJSON(fmaWsUrl, function () {
const promise_track_api_params = $.getJSON(fmaWsUrl, function () {
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api_params.state()}`);
}).done(function (trackinfojson) {
LOGGER.debug(' >> Track INFO > DONE');
Expand All @@ -404,7 +404,7 @@
release_attributes.albumid
}&limit=20&page=${parseInt(page)}`;

var promise_track_api = $.getJSON(fmaWsUrl, function () {
const promise_track_api = $.getJSON(fmaWsUrl, function () {
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api.state()}`);
}).done(function (tracksjson) {
LOGGER.debug(` >> Track page ${page} > DONE `);
Expand Down Expand Up @@ -434,7 +434,7 @@
if (FMAtype == 'album') {
//LOGGER.debug("FMA parseFMApage Function Executing on ", FMAtype);
let FMAEmbedCode = $('.inp-embed-code input').attr('value');
FMAEmbedCodeRegex = /(\/embed\/album\/)(.+?(?=.xml))/; // regex to find the album id from the input object
const FMAEmbedCodeRegex = /(\/embed\/album\/)(.+?(?=.xml))/; // regex to find the album id from the input object
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
release_attributes.albumid = FMAAlbumIdMatch[2].trim(); // assign the ID to a variable
LOGGER.info('FreeMusicArchive Album identified as: ', release_attributes.albumid);
Expand Down Expand Up @@ -484,13 +484,13 @@
if (albumobject === undefined) {
albumobject = [];
} else {
albumobject = albumobject;

Check warning on line 487 in fma_importer.user.js

View workflow job for this annotation

GitHub Actions / lint checks

'albumobject' is assigned to itself
}

if (trackobject === undefined) {
trackobject = [];
} else {
trackobject = trackobject;

Check warning on line 493 in fma_importer.user.js

View workflow job for this annotation

GitHub Actions / lint checks

'trackobject' is assigned to itself
}

let fmarelease = {};
Expand Down Expand Up @@ -578,7 +578,6 @@
name: release_attributes.label,
});

let discarray = [];
let trackarray = [];

// release_attributes.total_pages
Expand Down Expand Up @@ -610,10 +609,10 @@
);
//LOGGER.debug("Highest number disc:" + largest_disc);

for (var disccount = 1; disccount <= largest_disc; disccount++) {
for (let disccount = 1; disccount <= largest_disc; disccount++) {
// use this to map all the objects from trackarray with disc_number value of disccount to a new object
let tracklist_per_disc = $.map(trackarray, function (obj, index) {
if (obj.disc_number == disccount) {
let tracklist_per_disc = $.map(trackarray, function (obj) {
if (obj.disc_number === disccount) {
return obj;
}
});
Expand All @@ -629,7 +628,7 @@
// });

// current solution to remove disc_number
for (i = tracklist_per_disc.length - 1; i >= 0; i--) {
for (let i = tracklist_per_disc.length - 1; i >= 0; i--) {
delete tracklist_per_disc[i].disc_number;
}

Expand Down
18 changes: 8 additions & 10 deletions lib/mbimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*
*/

const MBImport = (function () {

Check warning on line 63 in lib/mbimport.js

View workflow job for this annotation

GitHub Actions / lint checks

'MBImport' is assigned a value but never used
// --------------------------------------- publics ----------------------------------------- //

const special_artists = {
Expand Down Expand Up @@ -270,29 +270,27 @@
// re-split artists if featuring or vs
artists.map(function (item) {
let c = item.artist_name.replace(/\s*\b(?:feat\.?|ft\.?|featuring)\s+/gi, ' feat. ');
c = c.replace(/\s*\(( feat. )([^\)]+)\)/g, '$1$2');
c = c.replace(/\s*\(( feat. )([^)]+)\)/g, '$1$2');
c = c.replace(/\s*\b(?:versus|vs\.?)\s+/gi, ' vs. ');
c = c.replace(/\s+/g, ' ');
let splitted = c.split(/( feat\. | vs\. )/);
if (splitted.length == 1) {
if (splitted.length === 1) {
credits.push(item); // nothing to split
} else {
let new_items = [];
let n = 0;
for (let i = 0; i < splitted.length; i++) {
if (n && (splitted[i] == ' feat. ' || splitted[i] == ' vs. ')) {
new_items[n - 1].joinphrase = splitted[i];
for (const element of splitted) {
if (n && (element === ' feat. ' || element === ' vs. ')) {
new_items[n - 1].joinphrase = element;
} else {
new_items[n++] = {
artist_name: splitted[i].trim(),
artist_name: element.trim(),
joinphrase: '',
};
}
}
new_items[n - 1].joinphrase = item.joinphrase;
new_items.map(function (newit) {
credits.push(newit);
});
new_items.forEach(newit => credits.push(newit));
}
});
return credits;
Expand Down Expand Up @@ -361,7 +359,7 @@
}

function luceneEscape(text) {
let newtext = text.replace(/[-[\]{}()*+?~:\\^!"\/]/g, '\\$&');
let newtext = text.replace(/[-[\]{}()*+?~:\\^!"/]/g, '\\$&');
return newtext.replace('&&', '&&').replace('||', '||');
}

Expand Down
17 changes: 6 additions & 11 deletions lib/mblinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,29 @@ const MBLinks = function (user_cache_key, version, expiration) {

this.removeOldCacheVersions = function () {
let to_remove = [];
for (var i = 0, len = localStorage.length; i < len; ++i) {
for (let i = 0, len = localStorage.length; i < len; ++i) {
let key = localStorage.key(i);
if (key.indexOf(this.user_cache_key) === 0) {
if (key != this.cache_key) {
if (key.startsWith(this.user_cache_key)) {
if (key !== this.cache_key) {
// we don't want to remove current cache
to_remove.push(key);
}
}
}
// remove old cache keys
for (var i = 0; i < to_remove.length; i++) {
localStorage.removeItem(to_remove[i]);
for (const element of to_remove) {
localStorage.removeItem(element);
}
};

this.clearCacheExpired = function () {
//var old_cache_entries = Object.keys(this.cache).length;
//console.log("clearCacheExpired " + old_cache_entries);
let now = new Date().getTime();
let new_cache = {};
let that = this;
$.each(this.cache, function (key, value) {
$.each(this.cache, function (key) {
if (that.is_cached(key)) {
new_cache[key] = that.cache[key];
}
});
//var new_cache_entries = Object.keys(new_cache).length;
//console.log("Cleared cache entries: " + old_cache_entries + ' -> ' + new_cache_entries);
this.cache = new_cache;
};

Expand Down
28 changes: 14 additions & 14 deletions loot_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ function ParseLootPage() {
releaseartist = AlbumName[1].innerText;
if (releaseartist == 'Various Artists') {
// Everything is: title(format)
releaseartisttitle_regex = /(.*?)\((.*)\)/; //match external parenthesis
const releaseartisttitle_regex = /(.*?)\((.*)\)/; //match external parenthesis
if (AlbumName[0].innerText.match(releaseartisttitle_regex)) {
releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
const releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
releasetitle = releaseartisttitle[1].trim();
release_format = releaseartisttitle[2];
} else {
Expand All @@ -180,10 +180,10 @@ function ParseLootPage() {
}
} else {
// artist - title(format)
releaseartisttitle_regex = /(.*) (-|–) (.*?)\((.*)\)/;
const releaseartisttitle_regex = /(.*) (-|–) (.*?)\((.*)\)/;

if (AlbumName[0].innerText.match(releaseartisttitle_regex)) {
releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
const releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);

releasetitle = releaseartisttitle[3].trim();
releaseartist = releaseartisttitle[1];
Expand Down Expand Up @@ -262,22 +262,22 @@ function ParseLootPage() {
let tracklisting = allinfolist[disciterate].getElementsByTagName('tr');
LOGGER.debug(' The Table: (tracklisting)', tracklisting);

for (let trackiterate = 0; trackiterate < tracklisting.length; trackiterate++) {
descriptiontrack = new Object();
for (const element of tracklisting) {
const descriptiontrack = new Object();

let currenttrack = tracklisting[trackiterate].querySelectorAll('td');
let currenttrack = element.querySelectorAll('td');
// var artisttitle_regex = /(.*) - (.*)/; // regex: artist - title
var artisttitle_regex = /(.*) (-|–) (.*)/; // regex: artist - title char 45 or 8211

// need to check if this can be replaced with single regex for now check artist-title if
// not matching check just title
if (currenttrack[1].innerText.match(artisttitle_regex)) {
var artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
const artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
descriptiontrack.title = artisttitle[3];
descriptiontrack.artist = artisttitle[1];
} else {
var artisttitle_regex = /(.*)/; // regex: title
var artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
const artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
descriptiontrack.title = artisttitle[1];
descriptiontrack.artist = releaseartist;
}
Expand Down Expand Up @@ -315,17 +315,17 @@ function ParseLootPage() {
}

//LOGGER.debug(disclistarray);
release = new Object();
const release = {};

// Check if anything is untoward and highlight to importer
release.maybe_buggy = release_maybe_buggy;

// Release artist credit
release.artist_credit = new Array();
release.artist_credit = [];

let artist_name = releaseartist;

let various_artists = releaseartist == 'Various Artists';
let various_artists = releaseartist === 'Various Artists';
if (various_artists) {
release.artist_credit = [MBImport.specialArtist('various_artists')];
} else {
Expand All @@ -346,7 +346,7 @@ function ParseLootPage() {
release.country = Countries[releasecountry];
release.language = Languages[releaselanguage];

release.discs = new Array();
release.discs = [];
for (let l = 0; l < disccount.length; l++) {
let disc = {
position: l + 1,
Expand All @@ -359,7 +359,7 @@ function ParseLootPage() {
release.labels = prodlabels;

// Release URL
release.urls = new Array();
release.urls = [];
release.urls.push({
url: window.location.href,
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
Expand Down
Loading
Loading