mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-11-10 05:04:13 +00:00
Reformat with prettier 2.0
This commit is contained in:
parent
650eb91b04
commit
0e864d8c59
27 changed files with 597 additions and 823 deletions
|
@ -20,13 +20,13 @@ this.$ = this.jQuery = jQuery.noConflict(true);
|
|||
|
||||
if (!unsafeWindow) unsafeWindow = window;
|
||||
|
||||
String.prototype.fix_bandcamp_url = function() {
|
||||
String.prototype.fix_bandcamp_url = function () {
|
||||
return this.replace('http://', 'https://');
|
||||
};
|
||||
|
||||
var BandcampImport = {
|
||||
// Analyze Bandcamp data and return a release object
|
||||
retrieveReleaseInfo: function() {
|
||||
retrieveReleaseInfo: function () {
|
||||
let bandcampAlbumData = unsafeWindow.TralbumData;
|
||||
let bandcampEmbedData = unsafeWindow.EmbedData;
|
||||
|
||||
|
@ -48,7 +48,7 @@ var BandcampImport = {
|
|||
language: 'eng',
|
||||
script: 'Latn',
|
||||
urls: [],
|
||||
url: bandcampAlbumData.url.fix_bandcamp_url()
|
||||
url: bandcampAlbumData.url.fix_bandcamp_url(),
|
||||
};
|
||||
|
||||
// Grab release title
|
||||
|
@ -83,7 +83,7 @@ var BandcampImport = {
|
|||
// Tracks
|
||||
let disc = {
|
||||
tracks: [],
|
||||
format: release.format
|
||||
format: release.format,
|
||||
};
|
||||
release.discs.push(disc);
|
||||
|
||||
|
@ -107,7 +107,7 @@ var BandcampImport = {
|
|||
}
|
||||
|
||||
let tracks_streamable = 0;
|
||||
$.each(bandcampAlbumData.trackinfo, function(index, bctrack) {
|
||||
$.each(bandcampAlbumData.trackinfo, function (index, bctrack) {
|
||||
let title = bctrack.title;
|
||||
let artist = [];
|
||||
if (various_artists) {
|
||||
|
@ -121,7 +121,7 @@ var BandcampImport = {
|
|||
let track = {
|
||||
title: title,
|
||||
duration: Math.round(bctrack.duration * 1000),
|
||||
artist_credit: MBImport.makeArtistCredits(artist)
|
||||
artist_credit: MBImport.makeArtistCredits(artist),
|
||||
};
|
||||
disc.tracks.push(track);
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ var BandcampImport = {
|
|||
let track = {
|
||||
title: '[unknown]',
|
||||
duration: null,
|
||||
artist_credit: []
|
||||
artist_credit: [],
|
||||
};
|
||||
disc.tracks.push(track);
|
||||
}
|
||||
|
@ -166,13 +166,13 @@ var BandcampImport = {
|
|||
) {
|
||||
release.urls.push({
|
||||
url: release.url,
|
||||
link_type: link_type.download_for_free
|
||||
link_type: link_type.download_for_free,
|
||||
});
|
||||
}
|
||||
if (bandcampAlbumData.current.download_pref === 2) {
|
||||
release.urls.push({
|
||||
url: release.url,
|
||||
link_type: link_type.purchase_for_download
|
||||
link_type: link_type.purchase_for_download,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -180,14 +180,14 @@ var BandcampImport = {
|
|||
if (bandcampAlbumData.hasAudio && !nostream && disc.tracks.length > 0 && disc.tracks.length == tracks_streamable) {
|
||||
release.urls.push({
|
||||
url: release.url,
|
||||
link_type: link_type.stream_for_free
|
||||
link_type: link_type.stream_for_free,
|
||||
});
|
||||
}
|
||||
// Check if release is Creative Commons licensed
|
||||
if ($('div#license a.cc-icons').length > 0) {
|
||||
release.urls.push({
|
||||
url: $('div#license a.cc-icons').attr('href'),
|
||||
link_type: link_type.license
|
||||
link_type: link_type.license,
|
||||
});
|
||||
}
|
||||
// Check if album has a back link to a label
|
||||
|
@ -196,7 +196,7 @@ var BandcampImport = {
|
|||
release.labels.push({
|
||||
name: label,
|
||||
mbid: '',
|
||||
catno: 'none'
|
||||
catno: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ var BandcampImport = {
|
|||
},
|
||||
|
||||
// Insert links in page
|
||||
insertLink: function(release) {
|
||||
insertLink: function (release) {
|
||||
if (release.type == 'track') {
|
||||
// only import album or single, tracks belong to an album
|
||||
return false;
|
||||
|
@ -223,31 +223,29 @@ var BandcampImport = {
|
|||
},
|
||||
|
||||
// helper to convert bandcamp date to MB date
|
||||
convdate: function(date) {
|
||||
convdate: function (date) {
|
||||
if (typeof date != 'undefined' && date !== '') {
|
||||
let d = new Date(date);
|
||||
return {
|
||||
year: d.getUTCFullYear(),
|
||||
month: d.getUTCMonth() + 1,
|
||||
day: d.getUTCDate()
|
||||
day: d.getUTCDate(),
|
||||
};
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// get label name from back link if possible
|
||||
getlabelname: function() {
|
||||
let label = $('a.back-to-label-link span.back-link-text')
|
||||
.contents()
|
||||
.get(2);
|
||||
getlabelname: function () {
|
||||
let label = $('a.back-to-label-link span.back-link-text').contents().get(2);
|
||||
if (typeof label == 'undefined') {
|
||||
return '';
|
||||
}
|
||||
return label.textContent;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
/* keep the following line as first, it is required to skip
|
||||
* pages which aren't actually a bandcamp page, since we support
|
||||
* bandcamp pages under third-party domains.
|
||||
|
@ -265,13 +263,13 @@ $(document).ready(function() {
|
|||
// add MB artist link
|
||||
let root_url = release.url.match(/^(https?:\/\/[^\/]+)/)[1].split('?')[0];
|
||||
let label_url = '';
|
||||
mblinks.searchAndDisplayMbLink(root_url, 'artist', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(root_url, 'artist', function (link) {
|
||||
$('div#name-section span[itemprop="byArtist"]').before(link);
|
||||
});
|
||||
mblinks.searchAndDisplayMbLink(
|
||||
root_url,
|
||||
'label',
|
||||
function(link) {
|
||||
function (link) {
|
||||
$('p#band-name-location span.title').append(link);
|
||||
},
|
||||
`label:${root_url}`
|
||||
|
@ -287,7 +285,7 @@ $(document).ready(function() {
|
|||
mblinks.searchAndDisplayMbLink(
|
||||
label_url,
|
||||
'label',
|
||||
function(link) {
|
||||
function (link) {
|
||||
$('a.back-to-label-link span.back-link-text').append(link);
|
||||
},
|
||||
`label:${label_url}`
|
||||
|
@ -311,17 +309,14 @@ $(document).ready(function() {
|
|||
label_name = BandcampImport.getlabelname();
|
||||
} else {
|
||||
label_mbid = mblinks.resolveMBID(`label:${root_url}`);
|
||||
if (label_mbid)
|
||||
label_name = $('p#band-name-location span.title')
|
||||
.text()
|
||||
.trim();
|
||||
if (label_mbid) label_name = $('p#band-name-location span.title').text().trim();
|
||||
}
|
||||
if (label_mbid || label_name) {
|
||||
if (release.labels.length == 0) {
|
||||
release.labels.push({
|
||||
name: '',
|
||||
mbid: '',
|
||||
catno: 'none'
|
||||
catno: 'none',
|
||||
});
|
||||
}
|
||||
release.labels[0].name = label_name;
|
||||
|
@ -333,12 +328,12 @@ $(document).ready(function() {
|
|||
|
||||
if (release.type == 'track') {
|
||||
// add MB links to parent album
|
||||
mblinks.searchAndDisplayMbLink(release.parent_album_url, 'release', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(release.parent_album_url, 'release', function (link) {
|
||||
$('div#name-section span[itemprop="inAlbum"] a:first').before(link);
|
||||
});
|
||||
} else {
|
||||
// add MB release links to album or single
|
||||
mblinks.searchAndDisplayMbLink(release.url, 'release', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(release.url, 'release', function (link) {
|
||||
$('div#name-section span[itemprop="byArtist"]').after(link);
|
||||
});
|
||||
}
|
||||
|
@ -347,9 +342,7 @@ $(document).ready(function() {
|
|||
$('div.tralbum-tags a:not(:last-child).tag').after(', ');
|
||||
|
||||
// append a link to the full size image
|
||||
let fullsizeimageurl = $('div#tralbumArt a')
|
||||
.attr('href')
|
||||
.replace('_10', '_0');
|
||||
let fullsizeimageurl = $('div#tralbumArt a').attr('href').replace('_10', '_0');
|
||||
$('div#tralbumArt').after(
|
||||
`<div id='bci_link'><a class='custom-color' href='${fullsizeimageurl}' title='Open original image in a new tab (Bandcamp importer)' target='_blank'>Original image</a></div>`
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ this.$ = this.jQuery = jQuery.noConflict(true);
|
|||
|
||||
if (!unsafeWindow) unsafeWindow = window;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Display a link to the correct album bandcamp url (ie. main page or releases page)
|
||||
let bandcampAlbumData = unsafeWindow.TralbumData;
|
||||
if (bandcampAlbumData && bandcampAlbumData.url) {
|
||||
|
|
|
@ -144,7 +144,7 @@ function batch_recording_rels() {
|
|||
return {
|
||||
year: parseIntegerOrNull(match[1]),
|
||||
month: parseIntegerOrNull(match[2]),
|
||||
day: parseIntegerOrNull(match[3])
|
||||
day: parseIntegerOrNull(match[3]),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ function batch_recording_rels() {
|
|||
|
||||
let daysInMonth = {
|
||||
true: [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
||||
false: [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
false: [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
||||
};
|
||||
|
||||
function isDateValid(y, m, d) {
|
||||
|
@ -173,7 +173,7 @@ function batch_recording_rels() {
|
|||
// Request rate limiting
|
||||
|
||||
let REQUEST_COUNT = 0;
|
||||
setInterval(function() {
|
||||
setInterval(function () {
|
||||
if (REQUEST_COUNT > 0) {
|
||||
REQUEST_COUNT -= 1;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ function batch_recording_rels() {
|
|||
this.stopped = false;
|
||||
}
|
||||
|
||||
RequestManager.prototype.next = function() {
|
||||
RequestManager.prototype.next = function () {
|
||||
if (this.stopped || !this.queue.length) {
|
||||
this.active = false;
|
||||
return;
|
||||
|
@ -202,7 +202,7 @@ function batch_recording_rels() {
|
|||
let timeout = diff * 1000;
|
||||
|
||||
setTimeout(
|
||||
function(self) {
|
||||
function (self) {
|
||||
self.next();
|
||||
},
|
||||
this.rate + timeout,
|
||||
|
@ -210,7 +210,7 @@ function batch_recording_rels() {
|
|||
);
|
||||
} else {
|
||||
setTimeout(
|
||||
function(self) {
|
||||
function (self) {
|
||||
self.next();
|
||||
},
|
||||
this.rate,
|
||||
|
@ -219,34 +219,34 @@ function batch_recording_rels() {
|
|||
}
|
||||
};
|
||||
|
||||
RequestManager.prototype.push_get = function(url, cb) {
|
||||
this.push(function() {
|
||||
RequestManager.prototype.push_get = function (url, cb) {
|
||||
this.push(function () {
|
||||
$.get(url, cb);
|
||||
});
|
||||
};
|
||||
|
||||
RequestManager.prototype.unshift_get = function(url, cb) {
|
||||
this.unshift(function() {
|
||||
RequestManager.prototype.unshift_get = function (url, cb) {
|
||||
this.unshift(function () {
|
||||
$.get(url, cb);
|
||||
});
|
||||
};
|
||||
|
||||
RequestManager.prototype.push = function(req) {
|
||||
RequestManager.prototype.push = function (req) {
|
||||
this.queue.push(req);
|
||||
this.maybe_start_queue();
|
||||
};
|
||||
|
||||
RequestManager.prototype.unshift = function(req) {
|
||||
RequestManager.prototype.unshift = function (req) {
|
||||
this.queue.unshift(req);
|
||||
this.maybe_start_queue();
|
||||
};
|
||||
|
||||
RequestManager.prototype.maybe_start_queue = function() {
|
||||
RequestManager.prototype.maybe_start_queue = function () {
|
||||
if (!(this.active || this.stopped)) {
|
||||
this.start_queue();
|
||||
}
|
||||
};
|
||||
RequestManager.prototype.start_queue = function() {
|
||||
RequestManager.prototype.start_queue = function () {
|
||||
if (this.active) {
|
||||
return;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ function batch_recording_rels() {
|
|||
} else {
|
||||
let timeout = this.rate - now + this.last;
|
||||
setTimeout(
|
||||
function(self) {
|
||||
function (self) {
|
||||
self.next();
|
||||
},
|
||||
timeout,
|
||||
|
@ -298,13 +298,13 @@ function batch_recording_rels() {
|
|||
[/–/g, '-'],
|
||||
[/−/g, '-'],
|
||||
[/—/g, '-'],
|
||||
[/―/g, '--']
|
||||
[/―/g, '--'],
|
||||
];
|
||||
|
||||
function normalizeTitle(title) {
|
||||
title = title.toLowerCase().replace(/\s+/g, '');
|
||||
|
||||
_.each(ASCII_PUNCTUATION, function(val) {
|
||||
_.each(ASCII_PUNCTUATION, function (val) {
|
||||
title = title.replace(val[0], val[1]);
|
||||
});
|
||||
|
||||
|
@ -312,7 +312,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
let RECORDING_TITLES = _.chain($recordings)
|
||||
.map(function(row) {
|
||||
.map(function (row) {
|
||||
let $title = $(row).find(TITLE_SELECTOR),
|
||||
mbid = $title.attr('href').match(MBID_REGEX)[0],
|
||||
norm_title = normalizeTitle($title.text().match(WITHOUT_PAREN_CLAUSES_REGEX)[1]);
|
||||
|
@ -323,7 +323,7 @@ function batch_recording_rels() {
|
|||
.value();
|
||||
|
||||
let $work_options = _.chain(['type', 'language'])
|
||||
.map(function(kind) {
|
||||
.map(function (kind) {
|
||||
return [kind, $(`<select id="bpr-work-${kind}"></select>`)];
|
||||
})
|
||||
.fromPairs()
|
||||
|
@ -368,9 +368,7 @@ function batch_recording_rels() {
|
|||
let hide_pending_edits = setting('hide_pending_edits') === 'true' ? true : false;
|
||||
|
||||
function make_checkbox(func, default_val, lbl) {
|
||||
let chkbox = $('<input type="checkbox"/>')
|
||||
.on('change', func)
|
||||
.attr('checked', default_val);
|
||||
let chkbox = $('<input type="checkbox"/>').on('change', func).attr('checked', default_val);
|
||||
return label(chkbox, lbl);
|
||||
}
|
||||
|
||||
|
@ -389,32 +387,23 @@ function batch_recording_rels() {
|
|||
|
||||
let $recordings_load_msg = $('<span>Loading performance relationships…</span>');
|
||||
|
||||
$container
|
||||
.find('table')
|
||||
.find('td')
|
||||
.css('width', 'auto');
|
||||
$container
|
||||
.children('tbody')
|
||||
.children('tr')
|
||||
.children('td')
|
||||
.css({ padding: '0.5em', 'vertical-align': 'top' });
|
||||
$container.find('table').find('td').css('width', 'auto');
|
||||
$container.children('tbody').children('tr').children('td').css({ padding: '0.5em', 'vertical-align': 'top' });
|
||||
|
||||
// Get actual work types/languages
|
||||
ws_requests.unshift_get('/dialog?path=%2Fwork%2Fcreate', function(data) {
|
||||
ws_requests.unshift_get('/dialog?path=%2Fwork%2Fcreate', function (data) {
|
||||
let nodes = $.parseHTML(data);
|
||||
function populate($obj, kind) {
|
||||
$obj.append($(`#id-edit-work\\.${kind}_id`, nodes).children())
|
||||
.val(setting(`work_${kind}`) || 0)
|
||||
.on('change', function() {
|
||||
.on('change', function () {
|
||||
setting(`work_${kind}`, this.value);
|
||||
});
|
||||
}
|
||||
_.each($work_options, populate);
|
||||
});
|
||||
|
||||
$('<span></span>')
|
||||
.append('<img src="/static/images/icons/loading.gif"/> ', $recordings_load_msg)
|
||||
.insertBefore($relate_table);
|
||||
$('<span></span>').append('<img src="/static/images/icons/loading.gif"/> ', $recordings_load_msg).insertBefore($relate_table);
|
||||
|
||||
// Add additional column
|
||||
|
||||
|
@ -443,7 +432,7 @@ function batch_recording_rels() {
|
|||
);
|
||||
|
||||
$(document)
|
||||
.on('input', 'input.bpr-date-input', function() {
|
||||
.on('input', 'input.bpr-date-input', function () {
|
||||
let $input = $(this);
|
||||
|
||||
$input.css('border-color', '#999');
|
||||
|
@ -466,13 +455,13 @@ function batch_recording_rels() {
|
|||
$input.css('color', '#ddd');
|
||||
}
|
||||
})
|
||||
.on('click', 'span.bpr-attr', function() {
|
||||
.on('click', 'span.bpr-attr', function () {
|
||||
let $this = $(this);
|
||||
let checked = !$this.data('checked');
|
||||
|
||||
$this.data('checked', checked).css({
|
||||
background: checked ? 'blue' : 'inherit',
|
||||
color: checked ? 'white' : 'black'
|
||||
color: checked ? 'white' : 'black',
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -484,7 +473,7 @@ function batch_recording_rels() {
|
|||
'background-color': '#FFFFFF',
|
||||
border: '1px solid #D0D0D0',
|
||||
'border-top': '1px solid #EAEAEA',
|
||||
'border-left': '1px solid #EAEAEA'
|
||||
'border-left': '1px solid #EAEAEA',
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -496,7 +485,7 @@ function batch_recording_rels() {
|
|||
$rows.find('input[name=add-to-merge]').attr('checked', false);
|
||||
}
|
||||
|
||||
$('.tbl > thead input[type=checkbox]').on('change', function() {
|
||||
$('.tbl > thead input[type=checkbox]').on('change', function () {
|
||||
if (this.checked) {
|
||||
uncheckRows($recordings.filter(':hidden'));
|
||||
}
|
||||
|
@ -523,11 +512,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
let NAME_FILTER = $.trim($('#id-filter\\.name').val());
|
||||
let ARTIST_FILTER = $.trim(
|
||||
$('#id-filter\\.artist_credit_id')
|
||||
.find('option:selected')
|
||||
.text()
|
||||
);
|
||||
let ARTIST_FILTER = $.trim($('#id-filter\\.artist_credit_id').find('option:selected').text());
|
||||
|
||||
if (NAME_FILTER || ARTIST_FILTER) {
|
||||
get_filtered_page(0);
|
||||
|
@ -540,7 +525,7 @@ function batch_recording_rels() {
|
|||
function request_recordings(url) {
|
||||
let attempts = 1;
|
||||
|
||||
$.get(url, function(data) {
|
||||
$.get(url, function (data) {
|
||||
let recs = data.recordings;
|
||||
let cache = {};
|
||||
|
||||
|
@ -550,10 +535,7 @@ function batch_recording_rels() {
|
|||
if (row === undefined) {
|
||||
for (let j = 0; j < $recordings.length; j++) {
|
||||
let row_ = $recordings[j];
|
||||
let row_id = $(row_)
|
||||
.find(TITLE_SELECTOR)
|
||||
.attr('href')
|
||||
.match(MBID_REGEX)[0];
|
||||
let row_id = $(row_).find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
|
||||
|
||||
if (node.id === row_id) {
|
||||
row = row_;
|
||||
|
@ -581,12 +563,12 @@ function batch_recording_rels() {
|
|||
restripeRows();
|
||||
}
|
||||
})
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
$recordings_load_msg.parent().remove();
|
||||
$relate_table.show();
|
||||
load_works_init();
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
$recordings_load_msg.text(`Error loading relationships. Retry #${attempts}...`).css('color', 'red');
|
||||
attempts += 1;
|
||||
ws_requests.unshift(request_recordings);
|
||||
|
@ -594,7 +576,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
function queue_recordings_request(url) {
|
||||
ws_requests.push(function() {
|
||||
ws_requests.push(function () {
|
||||
request_recordings(url);
|
||||
});
|
||||
}
|
||||
|
@ -604,8 +586,8 @@ function batch_recording_rels() {
|
|||
ARTIST_FILTER ? `creditname:${encodeURIComponent(ARTIST_FILTER)}%20AND%20` : ''
|
||||
} arid:${ARTIST_MBID}&limit=100&offset=${page * 100}&fmt=json`;
|
||||
|
||||
ws_requests.push_get(url, function(data) {
|
||||
_.each(data.recordings, function(r) {
|
||||
ws_requests.push_get(url, function (data) {
|
||||
_.each(data.recordings, function (r) {
|
||||
queue_recordings_request(`/ws/2/recording/${r.id}?inc=work-rels&fmt=json`);
|
||||
});
|
||||
|
||||
|
@ -622,7 +604,7 @@ function batch_recording_rels() {
|
|||
$row.data('performances', []);
|
||||
$attrs.data('checked', false).css('color', 'black');
|
||||
|
||||
_.each(node.relations, function(rel) {
|
||||
_.each(node.relations, function (rel) {
|
||||
if (rel.type.match(/performance/)) {
|
||||
if (!performed) {
|
||||
$row.addClass('performed');
|
||||
|
@ -630,14 +612,11 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
if (rel.begin) {
|
||||
$attrs
|
||||
.find('input.date')
|
||||
.val(rel.begin)
|
||||
.trigger('input');
|
||||
$attrs.find('input.date').val(rel.begin).trigger('input');
|
||||
}
|
||||
|
||||
let attrs = [];
|
||||
_.each(rel.attributes, function(name) {
|
||||
_.each(rel.attributes, function (name) {
|
||||
let cannonical_name = name.toLowerCase();
|
||||
let $button = $attrs.find(`span.${cannonical_name}`);
|
||||
|
||||
|
@ -657,10 +636,7 @@ function batch_recording_rels() {
|
|||
let comment = node.disambiguation;
|
||||
let date = comment && comment.match && comment.match(/live(?: .+)?, ([0-9]{4}(?:-[0-9]{2}(?:-[0-9]{2})?)?)(?:\: .+)?$/);
|
||||
if (date) {
|
||||
$attrs
|
||||
.find('input.date')
|
||||
.val(date[1])
|
||||
.trigger('input');
|
||||
$attrs.find('input.date').val(date[1]).trigger('input');
|
||||
}
|
||||
|
||||
if (!performed) {
|
||||
|
@ -669,8 +645,8 @@ function batch_recording_rels() {
|
|||
} else {
|
||||
let url = `/ws/2/recording/${node.id}?inc=releases+release-groups&fmt=json`;
|
||||
|
||||
var request_rec = function() {
|
||||
$.get(url, function(data) {
|
||||
var request_rec = function () {
|
||||
$.get(url, function (data) {
|
||||
let releases = data.releases;
|
||||
|
||||
for (let i = 0; i < releases.length; i++) {
|
||||
|
@ -679,7 +655,7 @@ function batch_recording_rels() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
}).fail(function () {
|
||||
ws_requests.push(request_rec);
|
||||
});
|
||||
};
|
||||
|
@ -734,7 +710,7 @@ function batch_recording_rels() {
|
|||
$msg = $('<td></td>');
|
||||
|
||||
$button_cell.append(
|
||||
style_buttons($('<button>Remove</button>')).click(function() {
|
||||
style_buttons($('<button>Remove</button>')).click(function () {
|
||||
$table_row.remove();
|
||||
remove_artist_works(mbid);
|
||||
})
|
||||
|
@ -742,7 +718,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
let $reload = style_buttons($('<button>Reload</button>'))
|
||||
.click(function() {
|
||||
.click(function () {
|
||||
$button_cell.css('display', 'none');
|
||||
$msg.text(`Loading works for ${name}...`);
|
||||
load();
|
||||
|
@ -750,9 +726,7 @@ function batch_recording_rels() {
|
|||
.prependTo($button_cell);
|
||||
|
||||
$msg.text(`Loading works for ${name}...`).css('color', 'green'), $table_row.append($msg, $button_cell);
|
||||
$('tr#bpr-works-row')
|
||||
.css('display', 'none')
|
||||
.before($table_row);
|
||||
$('tr#bpr-works-row').css('display', 'none').before($table_row);
|
||||
|
||||
let works_date = localStorage.getItem(`bpr_works_date ${mbid}`);
|
||||
let result = [];
|
||||
|
@ -781,7 +755,7 @@ function batch_recording_rels() {
|
|||
localStorage.setItem(`bpr_works_date ${mbid}`, works_date);
|
||||
result = [];
|
||||
|
||||
let callback = function(loaded, remaining) {
|
||||
let callback = function (loaded, remaining) {
|
||||
result.push.apply(result, loaded);
|
||||
if (remaining > 0) {
|
||||
$msg.text(`Loading ${remaining.toString()} works for ${name}...`);
|
||||
|
@ -792,7 +766,7 @@ function batch_recording_rels() {
|
|||
};
|
||||
|
||||
let works_url = `/ws/2/work?artist=${mbid}&inc=aliases&limit=100&fmt=json`;
|
||||
ws_requests.unshift(function() {
|
||||
ws_requests.unshift(function () {
|
||||
request_works(works_url, 0, -1, callback);
|
||||
});
|
||||
}
|
||||
|
@ -806,7 +780,7 @@ function batch_recording_rels() {
|
|||
let tmp_comments = [];
|
||||
let tmp_norm_titles = [];
|
||||
|
||||
_.each(result, function(parts) {
|
||||
_.each(result, function (parts) {
|
||||
let mbid = parts.slice(0, 36);
|
||||
let rest = parts.slice(36).split('\u00a0');
|
||||
|
||||
|
@ -820,7 +794,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
function request_works(url, offset, count, callback) {
|
||||
$.get(`${url}&offset=${offset}`, function(data, textStatus, jqXHR) {
|
||||
$.get(`${url}&offset=${offset}`, function (data, textStatus, jqXHR) {
|
||||
if (count < 0) {
|
||||
count = data['work-count'];
|
||||
}
|
||||
|
@ -828,7 +802,7 @@ function batch_recording_rels() {
|
|||
let works = data.works;
|
||||
let loaded = [];
|
||||
|
||||
_.each(works, function(work) {
|
||||
_.each(works, function (work) {
|
||||
let comment = work.disambiguation;
|
||||
loaded.push(work.id + work.title + (comment ? `\u00a0${comment}` : ''));
|
||||
});
|
||||
|
@ -836,12 +810,12 @@ function batch_recording_rels() {
|
|||
callback(loaded, count - offset - works.length);
|
||||
|
||||
if (works.length + offset < count) {
|
||||
ws_requests.unshift(function() {
|
||||
ws_requests.unshift(function () {
|
||||
request_works(url, offset + 100, count, callback);
|
||||
});
|
||||
}
|
||||
}).fail(function() {
|
||||
ws_requests.unshift(function() {
|
||||
}).fail(function () {
|
||||
ws_requests.unshift(function () {
|
||||
request_works(url, offset, count, callback);
|
||||
});
|
||||
});
|
||||
|
@ -865,7 +839,7 @@ function batch_recording_rels() {
|
|||
|
||||
let matches = {};
|
||||
|
||||
let to_recording = function($rec, rec_title) {
|
||||
let to_recording = function ($rec, rec_title) {
|
||||
if (rec_title in matches) {
|
||||
let match = matches[rec_title];
|
||||
suggested_work_link($rec, match[0], match[1], match[2]);
|
||||
|
@ -883,7 +857,7 @@ function batch_recording_rels() {
|
|||
let context = { minScore: 0.250001, match: null };
|
||||
let total = mbids.length;
|
||||
|
||||
let done = function() {
|
||||
let done = function () {
|
||||
let match = context.match;
|
||||
if (match !== null) {
|
||||
matches[rec_title] = match;
|
||||
|
@ -893,7 +867,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
};
|
||||
|
||||
var iid = setInterval(function() {
|
||||
var iid = setInterval(function () {
|
||||
let j = current++;
|
||||
let norm_work_title = norm_titles[j];
|
||||
let score = sim(rec_title, norm_work_title);
|
||||
|
@ -920,10 +894,7 @@ function batch_recording_rels() {
|
|||
|
||||
for (let i = 0; i < $not_performed.length; i++) {
|
||||
let $rec = $not_performed.eq(i);
|
||||
let mbid = $rec
|
||||
.find(TITLE_SELECTOR)
|
||||
.attr('href')
|
||||
.match(MBID_REGEX)[0];
|
||||
let mbid = $rec.find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
|
||||
|
||||
to_recording($rec, RECORDING_TITLES[mbid]);
|
||||
}
|
||||
|
@ -937,9 +908,7 @@ function batch_recording_rels() {
|
|||
.append(
|
||||
$('<span>Suggested work:</span>').css({ color: 'green', 'font-weight': 'bold' }),
|
||||
' ',
|
||||
$('<a></a>')
|
||||
.attr('href', `/work/${mbid}`)
|
||||
.text(title),
|
||||
$('<a></a>').attr('href', `/work/${mbid}`).text(title),
|
||||
comment ? ' ' : null,
|
||||
comment ? $('<span></span>').text(`(${comment})`) : null
|
||||
)
|
||||
|
@ -958,7 +927,7 @@ function batch_recording_rels() {
|
|||
let item_key = `bpr_artists ${ARTIST_MBID}`;
|
||||
localStorage.setItem(
|
||||
item_key,
|
||||
_.filter(localStorage.getItem(item_key).split('\n'), function(artist) {
|
||||
_.filter(localStorage.getItem(item_key).split('\n'), function (artist) {
|
||||
return artist.slice(0, 36) !== mbid;
|
||||
}).join('\n')
|
||||
);
|
||||
|
@ -1000,7 +969,7 @@ function batch_recording_rels() {
|
|||
let mbid = $input.data('mbid');
|
||||
let name = $input.data('name');
|
||||
|
||||
load_artist_works(mbid, name).done(function() {
|
||||
load_artist_works(mbid, name).done(function () {
|
||||
let artists_string = localStorage.getItem(`bpr_artists ${ARTIST_MBID}`);
|
||||
if (artists_string) {
|
||||
artists_string += `\n${mbid}${name}`;
|
||||
|
@ -1032,16 +1001,11 @@ function batch_recording_rels() {
|
|||
for (let i = 0; i < total; i++) {
|
||||
let $row = $rows.eq(i);
|
||||
|
||||
$row.children('td')
|
||||
.not(':has(input)')
|
||||
.first()
|
||||
.css('color', 'LightSlateGray')
|
||||
.find('a')
|
||||
.css('color', 'LightSlateGray');
|
||||
$row.children('td').not(':has(input)').first().css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
|
||||
|
||||
let promise = relate_to_work($row, mbid, title, comment, false, false);
|
||||
if (i === total - 1) {
|
||||
promise.done(function() {
|
||||
promise.done(function () {
|
||||
deferred.resolve();
|
||||
});
|
||||
}
|
||||
|
@ -1066,9 +1030,7 @@ function batch_recording_rels() {
|
|||
|
||||
ws_requests.stopped = true;
|
||||
|
||||
let $button = $(this)
|
||||
.attr('disabled', true)
|
||||
.css('color', '#EAEAEA');
|
||||
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
|
||||
|
||||
function callback() {
|
||||
ws_requests.stopped = false;
|
||||
|
@ -1076,7 +1038,7 @@ function batch_recording_rels() {
|
|||
$button.attr('disabled', false).css('color', '#565656');
|
||||
}
|
||||
|
||||
create_new_work(title, function(data) {
|
||||
create_new_work(title, function (data) {
|
||||
let work = data.match(/\/work\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/);
|
||||
relate_all_to_work(work[1], title, '').done(callback);
|
||||
});
|
||||
|
@ -1113,26 +1075,21 @@ function batch_recording_rels() {
|
|||
|
||||
ws_requests.stopped = true;
|
||||
|
||||
let $button = $(this)
|
||||
.attr('disabled', true)
|
||||
.css('color', '#EAEAEA');
|
||||
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
|
||||
|
||||
$.each($rows, function(i, row) {
|
||||
$.each($rows, function (i, row) {
|
||||
let $row = $(row);
|
||||
let $title_cell = rowTitleCell($row);
|
||||
let title = $title_cell.find(TITLE_SELECTOR).text();
|
||||
|
||||
$title_cell
|
||||
.css('color', 'LightSlateGray')
|
||||
.find('a')
|
||||
.css('color', 'LightSlateGray');
|
||||
$title_cell.css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
|
||||
|
||||
create_new_work(title, function(data) {
|
||||
create_new_work(title, function (data) {
|
||||
let work = data.match(/\/work\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/);
|
||||
let promise = relate_to_work($row, work[1], title, '', true, true);
|
||||
|
||||
if (--total_rows === 0) {
|
||||
promise.done(function() {
|
||||
promise.done(function () {
|
||||
flush_work_cache();
|
||||
ws_requests.stopped = false;
|
||||
ws_requests.start_queue();
|
||||
|
@ -1146,13 +1103,13 @@ function batch_recording_rels() {
|
|||
function create_new_work(title, callback) {
|
||||
function post_edit() {
|
||||
let data = `edit-work.name=${title}`;
|
||||
_.each($work_options, function($obj, kind) {
|
||||
_.each($work_options, function ($obj, kind) {
|
||||
if ($obj.val()) {
|
||||
data += `&edit-work.${kind}_id=${$obj.val()}`;
|
||||
}
|
||||
});
|
||||
|
||||
$.post('/work/create', data, callback).fail(function() {
|
||||
$.post('/work/create', data, callback).fail(function () {
|
||||
edit_requests.unshift(post_edit);
|
||||
});
|
||||
}
|
||||
|
@ -1160,7 +1117,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
function relate_to_suggested_works() {
|
||||
let $rows = checked_recordings().filter(function() {
|
||||
let $rows = checked_recordings().filter(function () {
|
||||
return $(this).data('suggested_work_mbid');
|
||||
});
|
||||
|
||||
|
@ -1169,9 +1126,7 @@ function batch_recording_rels() {
|
|||
return;
|
||||
}
|
||||
|
||||
let $button = $(this)
|
||||
.attr('disabled', true)
|
||||
.css('color', '#EAEAEA');
|
||||
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
|
||||
ws_requests.stopped = true;
|
||||
|
||||
function callback() {
|
||||
|
@ -1180,16 +1135,13 @@ function batch_recording_rels() {
|
|||
$button.attr('disabled', false).css('color', '#565656');
|
||||
}
|
||||
|
||||
$.each($rows, function(i, row) {
|
||||
$.each($rows, function (i, row) {
|
||||
let $row = $(row);
|
||||
let mbid = $row.data('suggested_work_mbid');
|
||||
let title = $row.data('suggested_work_title');
|
||||
let $title_cell = rowTitleCell($row);
|
||||
|
||||
$title_cell
|
||||
.css('color', 'LightSlateGray')
|
||||
.find('a')
|
||||
.css('color', 'LightSlateGray');
|
||||
$title_cell.css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
|
||||
|
||||
let promise = relate_to_work($row, mbid, title, '', false, false);
|
||||
if (i === total - 1) {
|
||||
|
@ -1207,9 +1159,7 @@ function batch_recording_rels() {
|
|||
.text(`${attrs.join(' ')} recording of `)
|
||||
.css({ 'font-size': '0.9em', padding: '0.3em', 'padding-left': '1em' })
|
||||
.append(
|
||||
$('<a></a>')
|
||||
.attr('href', `/work/${mbid}`)
|
||||
.text(title),
|
||||
$('<a></a>').attr('href', `/work/${mbid}`).text(title),
|
||||
comment ? ' ' : null,
|
||||
comment ? $('<span></span>').text(`(${comment})`) : null
|
||||
)
|
||||
|
@ -1231,10 +1181,7 @@ function batch_recording_rels() {
|
|||
$row.data('performances', [work_mbid]);
|
||||
}
|
||||
|
||||
let rec_mbid = $row
|
||||
.find(TITLE_SELECTOR)
|
||||
.attr('href')
|
||||
.match(MBID_REGEX)[0];
|
||||
let rec_mbid = $row.find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
|
||||
let $title_cell = rowTitleCell($row);
|
||||
let title_link = $title_cell.children('a')[0];
|
||||
let $attrs = $row.children('td.bpr_attrs');
|
||||
|
@ -1254,7 +1201,7 @@ function batch_recording_rels() {
|
|||
'rel-editor.rels.0.entity.1.type': 'work',
|
||||
'rel-editor.rels.0.entity.1.gid': work_mbid,
|
||||
'rel-editor.rels.0.entity.0.type': 'recording',
|
||||
'rel-editor.rels.0.entity.0.gid': rec_mbid
|
||||
'rel-editor.rels.0.entity.0.gid': rec_mbid,
|
||||
};
|
||||
|
||||
let attrs = [];
|
||||
|
@ -1263,7 +1210,7 @@ function batch_recording_rels() {
|
|||
if (selected('instrumental')) attrs.push('c031ed4f-c9bb-4394-8cf5-e8ce4db512ae');
|
||||
if (selected('cover')) attrs.push('1e8536bd-6eda-3822-8e78-1c0f4d3d2113');
|
||||
|
||||
_.each(attrs, function(attr, index) {
|
||||
_.each(attrs, function (attr, index) {
|
||||
data[`rel-editor.rels.0.attributes.${index}.type.gid`] = attr;
|
||||
});
|
||||
|
||||
|
@ -1280,7 +1227,7 @@ function batch_recording_rels() {
|
|||
function post_edit() {
|
||||
$(title_link).css('color', 'green');
|
||||
|
||||
$.post('/relationship-editor', data, function() {
|
||||
$.post('/relationship-editor', data, function () {
|
||||
add_work_link($row, work_mbid, work_title, work_comment, selectedAttrs);
|
||||
|
||||
$(title_link).removeAttr('style');
|
||||
|
@ -1292,7 +1239,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
deferred.resolve();
|
||||
}).fail(function() {
|
||||
}).fail(function () {
|
||||
edit_requests.unshift(post_edit);
|
||||
});
|
||||
}
|
||||
|
@ -1316,10 +1263,7 @@ function batch_recording_rels() {
|
|||
|
||||
for (let i = 0; i < $recordings.length; i++) {
|
||||
let $rec = $recordings.eq(i);
|
||||
let title = $rec
|
||||
.find(TITLE_SELECTOR)
|
||||
.text()
|
||||
.toLowerCase();
|
||||
let title = $rec.find(TITLE_SELECTOR).text().toLowerCase();
|
||||
|
||||
if (title.indexOf(string) !== -1) {
|
||||
$rec.data('filtered', false);
|
||||
|
@ -1341,7 +1285,7 @@ function batch_recording_rels() {
|
|||
uncheckRows($performed.hide());
|
||||
} else {
|
||||
$performed
|
||||
.filter(function() {
|
||||
.filter(function () {
|
||||
return !$(this).data('filtered');
|
||||
})
|
||||
.show();
|
||||
|
@ -1351,12 +1295,8 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
function toggle_pending_edits(event, checked) {
|
||||
let $pending = $recordings.filter(function() {
|
||||
return $(this)
|
||||
.find(TITLE_SELECTOR)
|
||||
.parent()
|
||||
.parent()
|
||||
.is('span.mp');
|
||||
let $pending = $recordings.filter(function () {
|
||||
return $(this).find(TITLE_SELECTOR).parent().parent().is('span.mp');
|
||||
});
|
||||
hide_pending_edits = checked !== undefined ? checked : this.checked;
|
||||
|
||||
|
@ -1364,7 +1304,7 @@ function batch_recording_rels() {
|
|||
uncheckRows($pending.hide());
|
||||
} else {
|
||||
$pending
|
||||
.filter(function() {
|
||||
.filter(function () {
|
||||
return !$(this).data('filtered');
|
||||
})
|
||||
.show();
|
||||
|
@ -1375,7 +1315,7 @@ function batch_recording_rels() {
|
|||
toggle_pending_edits(null, hide_pending_edits);
|
||||
|
||||
function checked_recordings() {
|
||||
return $recordings.filter(':visible').filter(function() {
|
||||
return $recordings.filter(':visible').filter(function () {
|
||||
return $(this).find('input[name=add-to-merge]:checked').length;
|
||||
});
|
||||
}
|
||||
|
@ -1383,13 +1323,13 @@ function batch_recording_rels() {
|
|||
function entity_lookup(id_suffix, entity) {
|
||||
let $input = $(`<input type="text" id="bpr-${id_suffix}"/>`);
|
||||
$input
|
||||
.on('input', function() {
|
||||
.on('input', function () {
|
||||
let match = this.value.match(MBID_REGEX);
|
||||
$(this).data('selected', false);
|
||||
if (match) {
|
||||
let mbid = match[0];
|
||||
ws_requests
|
||||
.unshift_get(`/ws/2/${entity}/${mbid}?fmt=json`, function(data) {
|
||||
.unshift_get(`/ws/2/${entity}/${mbid}?fmt=json`, function (data) {
|
||||
let value = data.title || data.name;
|
||||
let out_data = { selected: true, mbid: mbid, name: value };
|
||||
|
||||
|
@ -1397,12 +1337,9 @@ function batch_recording_rels() {
|
|||
out_data.comment = data.disambiguation;
|
||||
}
|
||||
|
||||
$input
|
||||
.val(value)
|
||||
.data(out_data)
|
||||
.css('background', '#bbffbb');
|
||||
$input.val(value).data(out_data).css('background', '#bbffbb');
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
$input.css('background', '#ffaaaa');
|
||||
});
|
||||
} else {
|
||||
|
@ -1415,7 +1352,7 @@ function batch_recording_rels() {
|
|||
}
|
||||
|
||||
function restripeRows() {
|
||||
$recordings.filter(':visible').each(function(index, row) {
|
||||
$recordings.filter(':visible').each(function (index, row) {
|
||||
let even = (index + 1) % 2 === 0;
|
||||
row.className = row.className.replace(even ? 'odd' : 'even', even ? 'even' : 'odd');
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ this.$ = this.jQuery = jQuery.noConflict(true);
|
|||
|
||||
if (!unsafeWindow) unsafeWindow = window;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
|
||||
let release_url = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
|
||||
|
@ -29,7 +29,7 @@ $(document).ready(function() {
|
|||
function retrieveReleaseInfo(release_url) {
|
||||
function contains_or(selector, list) {
|
||||
selectors = [];
|
||||
$.each(list, function(ind, value) {
|
||||
$.each(list, function (ind, value) {
|
||||
selectors.push(`${selector}:contains("${value.replace('"', '\\"')}")`);
|
||||
});
|
||||
return selectors.join(',');
|
||||
|
@ -42,7 +42,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
'Data de lançamento',
|
||||
'Releasedatum',
|
||||
'Data di uscita',
|
||||
'リリース予定日'
|
||||
'リリース予定日',
|
||||
];
|
||||
let labels_strings = ['Labels', 'Sello', 'Gravadoras', 'Label', 'Etichetta', 'Editora', 'レーベル'];
|
||||
let catalog_strings = ['Catalog', 'Catálogo', 'Catalogue', 'Katalog', 'Catalogus', 'Catalogo', 'カタログ'];
|
||||
|
@ -55,37 +55,30 @@ function retrieveReleaseInfo(release_url) {
|
|||
release.urls = [];
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download,
|
||||
});
|
||||
|
||||
let releaseDate = $(contains_or('td.meta-data-label', release_date_strings))
|
||||
.next()
|
||||
.text()
|
||||
.split('-');
|
||||
let releaseDate = $(contains_or('td.meta-data-label', release_date_strings)).next().text().split('-');
|
||||
release.year = releaseDate[0];
|
||||
release.month = releaseDate[1];
|
||||
release.day = releaseDate[2];
|
||||
|
||||
release.labels = [];
|
||||
release.labels.push({
|
||||
name: $(contains_or('td.meta-data-label', labels_strings))
|
||||
.next()
|
||||
.text(),
|
||||
catno: $(contains_or('td.meta-data-label', catalog_strings))
|
||||
.next()
|
||||
.text()
|
||||
name: $(contains_or('td.meta-data-label', labels_strings)).next().text(),
|
||||
catno: $(contains_or('td.meta-data-label', catalog_strings)).next().text(),
|
||||
});
|
||||
|
||||
let release_artists = [];
|
||||
|
||||
// Tracks
|
||||
let tracks = [];
|
||||
unsafeWindow.$('span[data-json]').each(function(index, tagSoup) {
|
||||
unsafeWindow.$('span[data-json]').each(function (index, tagSoup) {
|
||||
let t = $.parseJSON($(tagSoup).attr('data-json'));
|
||||
release.title = t.release.name;
|
||||
|
||||
let artists = [];
|
||||
t.artists.forEach(function(artist) {
|
||||
t.artists.forEach(function (artist) {
|
||||
artists.push(artist.name);
|
||||
release_artists.push(artist.name);
|
||||
});
|
||||
|
@ -96,12 +89,12 @@ function retrieveReleaseInfo(release_url) {
|
|||
tracks.push({
|
||||
artist_credit: MBImport.makeArtistCredits(artists),
|
||||
title: title,
|
||||
duration: t.lengthMs
|
||||
duration: t.lengthMs,
|
||||
});
|
||||
});
|
||||
|
||||
let unique_artists = [];
|
||||
$.each(release_artists, function(i, el) {
|
||||
$.each(release_artists, function (i, el) {
|
||||
if ($.inArray(el, unique_artists) === -1) {
|
||||
unique_artists.push(el);
|
||||
}
|
||||
|
@ -115,7 +108,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
release.discs = [];
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: 'Digital Media'
|
||||
format: 'Digital Media',
|
||||
});
|
||||
|
||||
LOGGER.info('Parsed release: ', release);
|
||||
|
|
|
@ -21,7 +21,7 @@ this.$ = this.jQuery = jQuery.noConflict(true);
|
|||
|
||||
if (!unsafeWindow) unsafeWindow = window;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
|
||||
let release_url = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
|
||||
|
@ -48,18 +48,18 @@ function retrieveReleaseInfo(release_url) {
|
|||
type: '',
|
||||
urls: [],
|
||||
labels: [],
|
||||
discs: []
|
||||
discs: [],
|
||||
};
|
||||
|
||||
// URLs
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download,
|
||||
});
|
||||
|
||||
release.labels.push({
|
||||
name: ProductDetail.label.name,
|
||||
catno: ProductDetail.catalog
|
||||
catno: ProductDetail.catalog,
|
||||
});
|
||||
|
||||
// Reload Playables if empty
|
||||
|
@ -73,7 +73,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
let the_tracks = unsafeWindow.Playables.tracks;
|
||||
let seen_tracks = {}; // to shoot duplicates ...
|
||||
let release_artists = [];
|
||||
$.each(the_tracks, function(idx, track) {
|
||||
$.each(the_tracks, function (idx, track) {
|
||||
if (track.release.id !== ProductDetail.id) {
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
seen_tracks[track.id] = true;
|
||||
|
||||
let artists = [];
|
||||
$.each(track.artists, function(idx2, artist) {
|
||||
$.each(track.artists, function (idx2, artist) {
|
||||
artists.push(artist.name);
|
||||
release_artists.push(artist.name);
|
||||
});
|
||||
|
@ -95,12 +95,12 @@ function retrieveReleaseInfo(release_url) {
|
|||
tracks.push({
|
||||
artist_credit: MBImport.makeArtistCredits(artists),
|
||||
title: title,
|
||||
duration: track.duration.minutes
|
||||
duration: track.duration.minutes,
|
||||
});
|
||||
});
|
||||
|
||||
let unique_artists = [];
|
||||
$.each(release_artists, function(i, el) {
|
||||
$.each(release_artists, function (i, el) {
|
||||
if ($.inArray(el, unique_artists) === -1) {
|
||||
unique_artists.push(el);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
}
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: release.format
|
||||
format: release.format,
|
||||
});
|
||||
|
||||
LOGGER.info('Parsed release: ', release);
|
||||
|
|
|
@ -24,18 +24,12 @@
|
|||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
var CD1DImporter = {
|
||||
getFormats: function() {
|
||||
getFormats: function () {
|
||||
// get a list of existing formats, return id of the fragment and name
|
||||
let formats = $('#container-1 ul li.ui-state-default').map(function() {
|
||||
let formats = $('#container-1 ul li.ui-state-default').map(function () {
|
||||
return {
|
||||
id: $(this)
|
||||
.find('a:first')
|
||||
.attr('href')
|
||||
.split('#')[1]
|
||||
.split('-'),
|
||||
name: $(this)
|
||||
.find('span:first')
|
||||
.text()
|
||||
id: $(this).find('a:first').attr('href').split('#')[1].split('-'),
|
||||
name: $(this).find('span:first').text(),
|
||||
};
|
||||
});
|
||||
// remove "parent" formats : ie. digital when mp3 and flac are present
|
||||
|
@ -58,31 +52,27 @@ var CD1DImporter = {
|
|||
if (!formats[i].toremove) {
|
||||
cleanformats.push({
|
||||
id: formats[i].id.join('-'),
|
||||
name: formats[i].name
|
||||
name: formats[i].name,
|
||||
});
|
||||
}
|
||||
}
|
||||
return cleanformats;
|
||||
},
|
||||
|
||||
getTracks: function(id) {
|
||||
getTracks: function (id) {
|
||||
// extract discs & tracks
|
||||
let tracklists = `div#${id} div.tracklist table.tracklist-content`;
|
||||
let discs = [];
|
||||
$(tracklists).each(function() {
|
||||
$(tracklists).each(function () {
|
||||
disc = $(this)
|
||||
.find('tbody tr')
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
// $(this) is used more than once; cache it for performance.
|
||||
let row = $(this);
|
||||
|
||||
// For each row that's "mapped", return an object that
|
||||
// describes the first and second <td> in the row.
|
||||
let duration = row
|
||||
.find('td.tracklist-content-length')
|
||||
.text()
|
||||
.replace('"', '')
|
||||
.replace("' ", ':');
|
||||
let duration = row.find('td.tracklist-content-length').text().replace('"', '').replace("' ", ':');
|
||||
|
||||
// drop track number prefix (A A2 C3 01 05 etc...)
|
||||
let title = row
|
||||
|
@ -91,7 +81,7 @@ var CD1DImporter = {
|
|||
.replace(/^[0-9A-F][0-9]* /, '');
|
||||
return {
|
||||
title: title,
|
||||
duration: MBImport.hmsToMilliSeconds(duration)
|
||||
duration: MBImport.hmsToMilliSeconds(duration),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
@ -100,22 +90,22 @@ var CD1DImporter = {
|
|||
return discs;
|
||||
},
|
||||
|
||||
getArtists: function() {
|
||||
getArtists: function () {
|
||||
// get artists
|
||||
let artists = $('div.infos-releasegrp div.list-artist a')
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
return $(this).text();
|
||||
})
|
||||
.get();
|
||||
return MBImport.makeArtistCredits(artists);
|
||||
},
|
||||
|
||||
getAlbum: function() {
|
||||
getAlbum: function () {
|
||||
// get release title
|
||||
return $('h1').text();
|
||||
},
|
||||
|
||||
fromCurrentTime: function(offset_in_seconds) {
|
||||
fromCurrentTime: function (offset_in_seconds) {
|
||||
let millis = Date.now();
|
||||
if (!isNaN(offset_in_seconds)) {
|
||||
millis += offset_in_seconds * 1000;
|
||||
|
@ -127,11 +117,11 @@ var CD1DImporter = {
|
|||
return {
|
||||
year: yyyy,
|
||||
month: mm,
|
||||
day: dd
|
||||
day: dd,
|
||||
};
|
||||
},
|
||||
|
||||
getReleaseDate: function() {
|
||||
getReleaseDate: function () {
|
||||
// get release date and convert it to object
|
||||
let text = $('div.infos-releasegrp div.row-date').text();
|
||||
if (text == 'yesterday' || text == 'hier') {
|
||||
|
@ -169,15 +159,15 @@ var CD1DImporter = {
|
|||
return {
|
||||
year: parseInt(date[2], 10),
|
||||
month: parseInt(date[1], 10),
|
||||
day: parseInt(date[0], 10)
|
||||
day: parseInt(date[0], 10),
|
||||
};
|
||||
},
|
||||
|
||||
currentURL: function() {
|
||||
currentURL: function () {
|
||||
return window.location.href.replace(/\/[a-z]{2}\/album\//i, '/album/').split('#')[0];
|
||||
},
|
||||
|
||||
retrieveReleaseInfo: function(format) {
|
||||
retrieveReleaseInfo: function (format) {
|
||||
// Analyze CD1D data and return a release object
|
||||
let release = {
|
||||
artist_credit: this.getArtists(),
|
||||
|
@ -189,7 +179,7 @@ var CD1DImporter = {
|
|||
script: 'latn',
|
||||
barcode: '',
|
||||
urls: [],
|
||||
discs: []
|
||||
discs: [],
|
||||
};
|
||||
|
||||
// Grab release event information
|
||||
|
@ -205,14 +195,14 @@ var CD1DImporter = {
|
|||
release.format = 'Vinyl';
|
||||
release.urls.push({
|
||||
url: this.currentURL(),
|
||||
link_type: link_type.purchase_for_mail_order
|
||||
link_type: link_type.purchase_for_mail_order,
|
||||
});
|
||||
} else if (format.name.match(/cd/i)) {
|
||||
release.country = 'FR';
|
||||
release.format = 'CD';
|
||||
release.urls.push({
|
||||
url: this.currentURL(),
|
||||
link_type: link_type.purchase_for_mail_order
|
||||
link_type: link_type.purchase_for_mail_order,
|
||||
});
|
||||
} else if (format.name.match(/digital|mp3|flac|ogg|wav/i)) {
|
||||
release.country = 'XW';
|
||||
|
@ -220,32 +210,32 @@ var CD1DImporter = {
|
|||
release.format = 'Digital Media';
|
||||
release.urls.push({
|
||||
url: this.currentURL(),
|
||||
link_type: link_type.purchase_for_download
|
||||
link_type: link_type.purchase_for_download,
|
||||
});
|
||||
}
|
||||
|
||||
release.labels = $('div.infos-details div.row-structure')
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
return {
|
||||
name: $(this).text(),
|
||||
mbid: '',
|
||||
catno: 'none'
|
||||
catno: 'none',
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
// Tracks
|
||||
$.each(this.getTracks(format.id), function(ndisc, disc) {
|
||||
$.each(this.getTracks(format.id), function (ndisc, disc) {
|
||||
let thisdisc = {
|
||||
tracks: [],
|
||||
format: release.format
|
||||
format: release.format,
|
||||
};
|
||||
release.discs.push(thisdisc);
|
||||
$.each(this, function(ntrack, track) {
|
||||
$.each(this, function (ntrack, track) {
|
||||
thisdisc.tracks.push({
|
||||
title: track.title,
|
||||
duration: track.duration,
|
||||
artist_credit: []
|
||||
artist_credit: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -254,7 +244,7 @@ var CD1DImporter = {
|
|||
return release;
|
||||
},
|
||||
|
||||
insertLink: function(release, where, formatname) {
|
||||
insertLink: function (release, where, formatname) {
|
||||
// Insert links in page
|
||||
|
||||
// Form parameters
|
||||
|
@ -267,10 +257,10 @@ var CD1DImporter = {
|
|||
$('#mb_buttons').css({ 'margin-top': '6px' });
|
||||
$('form.musicbrainz_import').css({ display: 'inline-block', 'margin-right': '5px' });
|
||||
mbUI.slideDown();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
/* CD1D uses same page with hidden tabs for all formats */
|
||||
let formats = CD1DImporter.getFormats();
|
||||
|
|
|
@ -16,17 +16,15 @@
|
|||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
let release_url = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
|
||||
release_url = release_url.replace(/^(?:https?:\/\/)?(?:store\.)?(?:cdbaby\.com)\//, 'http://store.cdbaby.com/');
|
||||
|
||||
let release;
|
||||
let buttons = '';
|
||||
$('div.album-page-buy-button-container a').each(function() {
|
||||
let format = $(this)
|
||||
.attr('title')
|
||||
.trim();
|
||||
$('div.album-page-buy-button-container a').each(function () {
|
||||
let format = $(this).attr('title').trim();
|
||||
release = retrieveReleaseInfo(release_url, format);
|
||||
buttons += getImportButton(release, release_url, format);
|
||||
});
|
||||
|
@ -40,9 +38,7 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
// Release defaults
|
||||
let release = {
|
||||
artist_credit: '',
|
||||
title: $("h1 span[itemprop='name']")
|
||||
.text()
|
||||
.trim(),
|
||||
title: $("h1 span[itemprop='name']").text().trim(),
|
||||
year: 0,
|
||||
month: 0,
|
||||
day: 0,
|
||||
|
@ -55,7 +51,7 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
type: '',
|
||||
urls: [],
|
||||
labels: [],
|
||||
discs: []
|
||||
discs: [],
|
||||
};
|
||||
|
||||
let link_type = MBImport.URL_TYPES;
|
||||
|
@ -66,14 +62,14 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
release.format = 'Vinyl';
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: link_type.purchase_for_mail_order
|
||||
link_type: link_type.purchase_for_mail_order,
|
||||
});
|
||||
} else if (format.match(/^cd/i)) {
|
||||
release.country = 'US';
|
||||
release.format = 'CD';
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: link_type.purchase_for_mail_order
|
||||
link_type: link_type.purchase_for_mail_order,
|
||||
});
|
||||
} else if (format.match(/^download/i)) {
|
||||
release.country = 'XW';
|
||||
|
@ -81,14 +77,12 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
release.format = 'Digital Media';
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: link_type.purchase_for_download
|
||||
link_type: link_type.purchase_for_download,
|
||||
});
|
||||
}
|
||||
|
||||
// Release artist
|
||||
let artist = $("h2 span[itemprop='byArtist'] a")
|
||||
.text()
|
||||
.trim();
|
||||
let artist = $("h2 span[itemprop='byArtist'] a").text().trim();
|
||||
let various_artists = artist == 'Various';
|
||||
if (various_artists) {
|
||||
release.artist_credit = [MBImport.specialArtist('various_artists')];
|
||||
|
@ -96,41 +90,31 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
release.artist_credit = MBImport.makeArtistCredits([artist]);
|
||||
}
|
||||
|
||||
release.year = $("span[itemprop='datePublished']")
|
||||
.text()
|
||||
.trim();
|
||||
release.year = $("span[itemprop='datePublished']").text().trim();
|
||||
|
||||
// Tracks
|
||||
let tracks = [];
|
||||
let trackcount = 0;
|
||||
$("table.track-table tr[itemprop='track']").each(function() {
|
||||
$("table.track-table tr[itemprop='track']").each(function () {
|
||||
let artists = [];
|
||||
let trackno = tracks.length + 1;
|
||||
if (trackno == 1 && tracks.length) {
|
||||
// multiple "discs"
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: release.format
|
||||
format: release.format,
|
||||
});
|
||||
tracks = [];
|
||||
}
|
||||
let trackname = $(this)
|
||||
.find("meta[itemprop='name']")
|
||||
.attr('content')
|
||||
.trim();
|
||||
let tracklength = $(this)
|
||||
.find("meta[itemprop='duration']")
|
||||
.attr('content')
|
||||
.trim();
|
||||
let trackname = $(this).find("meta[itemprop='name']").attr('content').trim();
|
||||
let tracklength = $(this).find("meta[itemprop='duration']").attr('content').trim();
|
||||
|
||||
let track_artists = [];
|
||||
// FIXME various artists releases ...
|
||||
$(this)
|
||||
.find('div.track-artist')
|
||||
.each(function() {
|
||||
let artistname = $(this)
|
||||
.text()
|
||||
.trim();
|
||||
.each(function () {
|
||||
let artistname = $(this).text().trim();
|
||||
if (artistname) {
|
||||
track_artists.push(artistname);
|
||||
}
|
||||
|
@ -139,7 +123,7 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
let ac = {
|
||||
artist_credit: '',
|
||||
title: trackname,
|
||||
duration: MBImport.ISO8601toMilliSeconds(tracklength)
|
||||
duration: MBImport.ISO8601toMilliSeconds(tracklength),
|
||||
};
|
||||
if (!track_artists.length && various_artists) {
|
||||
ac.artist_credit = [MBImport.specialArtist('unknown')];
|
||||
|
@ -151,7 +135,7 @@ function retrieveReleaseInfo(release_url, format) {
|
|||
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: release.format
|
||||
format: release.format,
|
||||
});
|
||||
|
||||
LOGGER.info('Parsed release: ', release);
|
||||
|
@ -169,11 +153,11 @@ function insertImportLinks(release, buttons) {
|
|||
$('#mb_buttons').css({
|
||||
'margin-bottom': '5px',
|
||||
padding: '2%',
|
||||
'background-color': '#fff'
|
||||
'background-color': '#fff',
|
||||
});
|
||||
|
||||
$('form.musicbrainz_import').css({
|
||||
'margin-bottom': '5px'
|
||||
'margin-bottom': '5px',
|
||||
});
|
||||
|
||||
$('#mb_buttons').slideDown();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
let gmXHR;
|
||||
|
||||
if (typeof GM_xmlhttpRequest != 'undefined') {
|
||||
|
@ -31,7 +31,7 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
// allow 1 second for Deezer SPA to initialize
|
||||
window.setTimeout(function() {
|
||||
window.setTimeout(function () {
|
||||
MBImportStyle();
|
||||
let releaseUrl = window.location.href.replace(/\?.*$/, '').replace(/#.*$/, '');
|
||||
let releaseId = releaseUrl.replace(/^https?:\/\/www\.deezer\.com\/[^/]+\/album\//i, '');
|
||||
|
@ -40,7 +40,7 @@ $(document).ready(function() {
|
|||
gmXHR({
|
||||
method: 'GET',
|
||||
url: deezerApiUrl,
|
||||
onload: function(resp) {
|
||||
onload: function (resp) {
|
||||
try {
|
||||
let release = parseDeezerRelease(releaseUrl, JSON.parse(resp.responseText));
|
||||
insertLink(release, releaseUrl);
|
||||
|
@ -48,10 +48,10 @@ $(document).ready(function() {
|
|||
LOGGER.error('Failed to parse release: ', e);
|
||||
}
|
||||
},
|
||||
onerror: function(resp) {
|
||||
onerror: function (resp) {
|
||||
LOGGER.error('AJAX status:', resp.status);
|
||||
LOGGER.error('AJAX response:', resp.responseText);
|
||||
}
|
||||
},
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
@ -73,15 +73,15 @@ function parseDeezerRelease(releaseUrl, data) {
|
|||
type: '',
|
||||
urls: [],
|
||||
labels: [],
|
||||
discs: []
|
||||
discs: [],
|
||||
};
|
||||
|
||||
$.each(data.contributors, function(index, artist) {
|
||||
$.each(data.contributors, function (index, artist) {
|
||||
if (artist.role != 'Main') return true;
|
||||
|
||||
let ac = {
|
||||
artist_name: artist.name,
|
||||
joinphrase: index == data.contributors.length - 1 ? '' : ', '
|
||||
joinphrase: index == data.contributors.length - 1 ? '' : ', ',
|
||||
};
|
||||
|
||||
if (artist.name == 'Various Artists') {
|
||||
|
@ -94,15 +94,15 @@ function parseDeezerRelease(releaseUrl, data) {
|
|||
let disc = {
|
||||
format: 'Digital Media',
|
||||
title: '',
|
||||
tracks: []
|
||||
tracks: [],
|
||||
};
|
||||
|
||||
$.each(data.tracks.data, function(index, track) {
|
||||
$.each(data.tracks.data, function (index, track) {
|
||||
let t = {
|
||||
number: index + 1,
|
||||
title: track.title_short,
|
||||
duration: track.duration * 1000,
|
||||
artist_credit: []
|
||||
artist_credit: [],
|
||||
};
|
||||
|
||||
// ignore pointless "(Original Mix)" in title version
|
||||
|
@ -119,7 +119,7 @@ function parseDeezerRelease(releaseUrl, data) {
|
|||
|
||||
release.urls.push({
|
||||
link_type: MBImport.URL_TYPES.stream_for_free,
|
||||
url: releaseUrl
|
||||
url: releaseUrl,
|
||||
});
|
||||
release.labels.push({ name: data.label });
|
||||
release.type = data.record_type;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* global $ MBImport */
|
||||
'use strict';
|
||||
var meta = function() {
|
||||
var meta = function () {
|
||||
// ==UserScript==
|
||||
// @name Import DG/Decca releases to MusicBrainz
|
||||
// @namespace https://github.com/murdos/musicbrainz-userscripts
|
||||
|
@ -38,19 +38,19 @@ var months = {
|
|||
'Sep.': 9,
|
||||
'Oct.': 10,
|
||||
'Nov.': 11,
|
||||
'Dec.': 12
|
||||
'Dec.': 12,
|
||||
};
|
||||
var labels = {
|
||||
'deutschegrammophon.com': {
|
||||
name: 'Deutsche Grammophon',
|
||||
mbid: '5a584032-dcef-41bb-9f8b-19540116fb1c',
|
||||
catno: document.URL.split('/')[5]
|
||||
catno: document.URL.split('/')[5],
|
||||
},
|
||||
'deccaclassics.com': {
|
||||
name: 'Decca Classics',
|
||||
mbid: '89a9993d-1dad-4445-a3d7-1d8df04f7e7b',
|
||||
catno: document.URL.split('/')[5]
|
||||
}
|
||||
catno: document.URL.split('/')[5],
|
||||
},
|
||||
};
|
||||
|
||||
var editNote = `Imported from ${document.URL}\n —\nGM script: "${meta.name}" (${meta.version})\n\n`;
|
||||
|
@ -97,12 +97,12 @@ function extract_release_data() {
|
|||
function _setReleasePerformers() {
|
||||
let list = $('div.artists')[0]
|
||||
.innerHTML.split('<br>')
|
||||
.map(function(artist) {
|
||||
.map(function (artist) {
|
||||
return {
|
||||
credited_name: artist,
|
||||
artist_name: artist,
|
||||
artist_mbid: '',
|
||||
joinphrase: ', '
|
||||
joinphrase: ', ',
|
||||
};
|
||||
});
|
||||
list[list.length - 1]['joinphrase'] = '';
|
||||
|
@ -116,8 +116,8 @@ function extract_release_data() {
|
|||
credited_name: composer,
|
||||
artist_name: composer,
|
||||
artist_mbid: '',
|
||||
joinphrase: '; '
|
||||
}
|
||||
joinphrase: '; ',
|
||||
},
|
||||
];
|
||||
return list.concat(_setReleasePerformers());
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ function extract_release_data() {
|
|||
let nodes = [];
|
||||
let tracklist_node = document.getElementById('tracklist');
|
||||
|
||||
$('.item,.hier0,.hier1,.hier2,.hier3').each(function(idx, node) {
|
||||
$('.item,.hier0,.hier1,.hier2,.hier3').each(function (idx, node) {
|
||||
var idx;
|
||||
let d = {};
|
||||
if (node.classList.contains('hier0')) {
|
||||
|
@ -166,7 +166,7 @@ function extract_release_data() {
|
|||
|
||||
// complete track titles
|
||||
let header0, header1, header2, idx;
|
||||
nodes.forEach(function(node, idx) {
|
||||
nodes.forEach(function (node, idx) {
|
||||
let level = node['level'],
|
||||
type = node['type'],
|
||||
content = node['title'];
|
||||
|
@ -194,7 +194,7 @@ function extract_release_data() {
|
|||
let discs = [],
|
||||
tracks = [],
|
||||
medium_title = '';
|
||||
nodes.forEach(function(item, idx) {
|
||||
nodes.forEach(function (item, idx) {
|
||||
if (item.type === 'track') {
|
||||
let track = extract_track_data(item.node);
|
||||
track.title = _clean(item.title);
|
||||
|
@ -205,7 +205,7 @@ function extract_release_data() {
|
|||
discs.push({
|
||||
title: '', // medium_title,
|
||||
format: 'CD',
|
||||
tracks: tracks
|
||||
tracks: tracks,
|
||||
});
|
||||
}
|
||||
medium_title = item.title;
|
||||
|
@ -216,7 +216,7 @@ function extract_release_data() {
|
|||
discs.push({
|
||||
title: '', // nodes[0].title,
|
||||
format: 'CD',
|
||||
tracks: tracks
|
||||
tracks: tracks,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -236,10 +236,10 @@ function extract_release_data() {
|
|||
urls: [
|
||||
{
|
||||
link_type: 288, // 'discography'
|
||||
url: document.URL
|
||||
}
|
||||
url: document.URL,
|
||||
},
|
||||
],
|
||||
discs: discs
|
||||
discs: discs,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -248,23 +248,23 @@ function extract_track_data(node) {
|
|||
console.log('artistString', artistString);
|
||||
let artists;
|
||||
if (artistString.includes(' | ')) {
|
||||
artists = artistString.split(' | ').map(function(artist) {
|
||||
artists = artistString.split(' | ').map(function (artist) {
|
||||
return {
|
||||
credited_name: artist.split(',')[0],
|
||||
artist_name: artist.split(',')[0],
|
||||
artist_mbid: '',
|
||||
joinphrase: ', '
|
||||
joinphrase: ', ',
|
||||
};
|
||||
});
|
||||
} else {
|
||||
artists = artistString.split(', ').map(function(artist, idx) {
|
||||
artists = artistString.split(', ').map(function (artist, idx) {
|
||||
let mbid = '';
|
||||
let url = `/ws/js/artist/?q=${artist}&fmt=json&limit=1`;
|
||||
return {
|
||||
credited_name: artist,
|
||||
artist_name: artist,
|
||||
artist_mbid: mbid,
|
||||
joinphrase: ', '
|
||||
joinphrase: ', ',
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -282,14 +282,8 @@ function extract_track_data(node) {
|
|||
} else {
|
||||
console.log('no meta data on ', node);
|
||||
schema.name = node.querySelectorAll('div.track-text > a.fancy')[0].textContent;
|
||||
schema.byArtist = $(node)
|
||||
.parent()
|
||||
.nextAll('div.container-container')
|
||||
.children('.artists-container')[0].textContent;
|
||||
let previousComposers = $(node)
|
||||
.parent()
|
||||
.prevAll('div.container-container')
|
||||
.children('.first-composer-container');
|
||||
schema.byArtist = $(node).parent().nextAll('div.container-container').children('.artists-container')[0].textContent;
|
||||
let previousComposers = $(node).parent().prevAll('div.container-container').children('.first-composer-container');
|
||||
schema.creator = previousComposers[previousComposers.length - 1].textContent;
|
||||
}
|
||||
console.info('schema', schema);
|
||||
|
@ -300,7 +294,7 @@ function extract_track_data(node) {
|
|||
artist_credit: _setTrackArtists(schema.byArtist), // CSG
|
||||
performer: schema.byArtist,
|
||||
composer: schema.creator,
|
||||
url: node.querySelectorAll('div.track-text > a.fancy')[0].href
|
||||
url: node.querySelectorAll('div.track-text > a.fancy')[0].href,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -321,7 +315,7 @@ function insertMBSection(release) {
|
|||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
width: '100%'
|
||||
width: '100%',
|
||||
});
|
||||
$('form.musicbrainz_import').css({ width: '49%', display: 'inline-block' });
|
||||
$('form.musicbrainz_import_search').css({ float: 'right' });
|
||||
|
|
|
@ -36,15 +36,12 @@ if (DEBUG) {
|
|||
|
||||
var mblinks = new MBLinks('DISCOGS_MBLINKS_CACHE', '1');
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
MBSearchItStyle();
|
||||
|
||||
let current_page_key = getDiscogsLinkKey(
|
||||
window.location.href
|
||||
.replace(/\?.*$/, '')
|
||||
.replace(/#.*$/, '')
|
||||
.replace('/master/view/', '/master/')
|
||||
window.location.href.replace(/\?.*$/, '').replace(/#.*$/, '').replace('/master/view/', '/master/')
|
||||
);
|
||||
if (!current_page_key) return;
|
||||
|
||||
|
@ -66,7 +63,7 @@ $(document).ready(function() {
|
|||
url: discogsWsUrl,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
LOGGER.debug('Discogs JSON Data from API:', data);
|
||||
try {
|
||||
let release = parseDiscogsRelease(data);
|
||||
|
@ -86,10 +83,10 @@ $(document).ready(function() {
|
|||
throw e;
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
LOGGER.error('AJAX Status: ', textStatus);
|
||||
LOGGER.error('AJAX error thrown: ', errorThrown);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -102,7 +99,7 @@ $(document).ready(function() {
|
|||
function insertMBLinks(current_page_key) {
|
||||
function searchAndDisplayMbLinkInSection($tr, discogs_type, mb_type, nosearch) {
|
||||
if (!mb_type) mb_type = defaultMBtype(discogs_type);
|
||||
$tr.find(`a[mlink^="${discogs_type}/"]`).each(function() {
|
||||
$tr.find(`a[mlink^="${discogs_type}/"]`).each(function () {
|
||||
let $link = $(this);
|
||||
if ($link.attr('mlink_stop')) return; // for places
|
||||
let mlink = $link.attr('mlink');
|
||||
|
@ -115,7 +112,7 @@ function insertMBLinks(current_page_key) {
|
|||
$link.attr(
|
||||
'mlink_done',
|
||||
done
|
||||
.filter(function(e) {
|
||||
.filter(function (e) {
|
||||
return e != '';
|
||||
})
|
||||
.join(',')
|
||||
|
@ -134,7 +131,7 @@ function insertMBLinks(current_page_key) {
|
|||
release: { mark: 'R' },
|
||||
'release-group': { mark: 'G' },
|
||||
place: { mark: 'P' },
|
||||
label: { mark: 'L' }
|
||||
label: { mark: 'L' },
|
||||
};
|
||||
let mark = '';
|
||||
let entity_name = 'entity';
|
||||
|
@ -151,15 +148,12 @@ function insertMBLinks(current_page_key) {
|
|||
)}"><small>${mark}</small>?</a></span>`
|
||||
);
|
||||
}
|
||||
let insert_normal = function(link) {
|
||||
let insert_normal = function (link) {
|
||||
$link.closest('span.mb_valign').before(`<span class="mb_valign">${link}</span>`);
|
||||
$link
|
||||
.closest('span.mb_wrapper')
|
||||
.find('.mb_searchit')
|
||||
.remove();
|
||||
$link.closest('span.mb_wrapper').find('.mb_searchit').remove();
|
||||
};
|
||||
|
||||
let insert_stop = function(link) {
|
||||
let insert_stop = function (link) {
|
||||
insert_normal(link);
|
||||
$link.attr('mlink_stop', true);
|
||||
};
|
||||
|
@ -188,7 +182,7 @@ function insertMBLinks(current_page_key) {
|
|||
'#B3FFC6',
|
||||
'#B3FFEC',
|
||||
'#B3ECFF',
|
||||
'#7598FF'
|
||||
'#7598FF',
|
||||
];
|
||||
if (DEBUG) {
|
||||
$(what).css('border', `2px dotted ${colors[n % colors.length]}`);
|
||||
|
@ -213,7 +207,7 @@ function insertMBLinks(current_page_key) {
|
|||
// just one string
|
||||
types = [types];
|
||||
}
|
||||
$.each(types, function(idx, val) {
|
||||
$.each(types, function (idx, val) {
|
||||
if (!$.isArray(val)) {
|
||||
types[idx] = [val, undefined];
|
||||
}
|
||||
|
@ -221,12 +215,12 @@ function insertMBLinks(current_page_key) {
|
|||
|
||||
LOGGER.debug(`add_mblinks: ${selector} / ${JSON.stringify(types)}`);
|
||||
|
||||
_root.find(selector).each(function() {
|
||||
_root.find(selector).each(function () {
|
||||
let node = $(this).get(0);
|
||||
magnifyLinks(node);
|
||||
debug_color(this, ++add_mblinks_counter, selector);
|
||||
let that = this;
|
||||
$.each(types, function(idx, val) {
|
||||
$.each(types, function (idx, val) {
|
||||
let discogs_type = val[0];
|
||||
let mb_type = val[1];
|
||||
searchAndDisplayMbLinkInSection($(that), discogs_type, mb_type, nosearch);
|
||||
|
@ -235,7 +229,7 @@ function insertMBLinks(current_page_key) {
|
|||
}
|
||||
|
||||
// Find MB link for the current page and display it next to page title
|
||||
let mbLinkInsert = function(link) {
|
||||
let mbLinkInsert = function (link) {
|
||||
let $h1 = $('h1');
|
||||
let $titleSpan = $h1.children('span[itemprop="name"]');
|
||||
if ($titleSpan.length > 0) {
|
||||
|
@ -301,7 +295,7 @@ function getDiscogsLinkKey(url) {
|
|||
link_infos[key] = {
|
||||
type: m[1],
|
||||
id: m[2],
|
||||
clean_url: `https://www.discogs.com/${m[1]}/${m[2]}`
|
||||
clean_url: `https://www.discogs.com/${m[1]}/${m[2]}`,
|
||||
};
|
||||
LOGGER.debug(`getDiscogsLinkKey:${url} --> ${key}`);
|
||||
} else {
|
||||
|
@ -415,7 +409,7 @@ function insertMBSection(release, current_page_key) {
|
|||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
width: '100%'
|
||||
width: '100%',
|
||||
});
|
||||
$('form.musicbrainz_import').css({ width: '49%', display: 'inline-block' });
|
||||
$('form.musicbrainz_import_search').css({ float: 'right' });
|
||||
|
@ -446,7 +440,7 @@ function artistNoNum(artist_name) {
|
|||
// Parse a US date string and set object properties year, month, day
|
||||
function parse_YYYY_MM_DD(date, obj) {
|
||||
if (!date) return;
|
||||
let m = date.split(/\D+/, 3).map(function(e) {
|
||||
let m = date.split(/\D+/, 3).map(function (e) {
|
||||
return parseInt(e, 10);
|
||||
});
|
||||
if (m[0] !== undefined) {
|
||||
|
@ -472,12 +466,12 @@ function parseDiscogsRelease(data) {
|
|||
|
||||
// Release artist credit
|
||||
release.artist_credit = [];
|
||||
$.each(discogsRelease.artists, function(index, artist) {
|
||||
$.each(discogsRelease.artists, function (index, artist) {
|
||||
let ac = {
|
||||
artist_name: artistNoNum(artist.name),
|
||||
credited_name: artist.anv != '' ? artist.anv : artistNoNum(artist.name),
|
||||
joinphrase: decodeDiscogsJoinphrase(artist.join),
|
||||
mbid: MBIDfromUrl(artist.resource_url, 'artist')
|
||||
mbid: MBIDfromUrl(artist.resource_url, 'artist'),
|
||||
};
|
||||
if (artist.id == 194) {
|
||||
// discogs place holder for various
|
||||
|
@ -508,11 +502,11 @@ function parseDiscogsRelease(data) {
|
|||
// Release labels
|
||||
release.labels = [];
|
||||
if (discogsRelease.labels) {
|
||||
$.each(discogsRelease.labels, function(index, label) {
|
||||
$.each(discogsRelease.labels, function (index, label) {
|
||||
let labelinfo = {
|
||||
name: label.name,
|
||||
catno: label.catno == 'none' ? '[none]' : label.catno,
|
||||
mbid: MBIDfromUrl(label.resource_url, 'label')
|
||||
mbid: MBIDfromUrl(label.resource_url, 'label'),
|
||||
};
|
||||
release.labels.push(labelinfo);
|
||||
});
|
||||
|
@ -535,7 +529,7 @@ function parseDiscogsRelease(data) {
|
|||
}
|
||||
|
||||
if (discogsRelease.formats[i].descriptions) {
|
||||
$.each(discogsRelease.formats[i].descriptions, function(index, desc) {
|
||||
$.each(discogsRelease.formats[i].descriptions, function (index, desc) {
|
||||
if (!(discogs_format in ['Box Set'])) {
|
||||
// Release format: special handling of Vinyl and Shellac 7", 10" and 12"
|
||||
if (desc.match(/7"|10"|12"/) && discogs_format.concat(desc) in MediaTypes)
|
||||
|
@ -579,7 +573,7 @@ function parseDiscogsRelease(data) {
|
|||
|
||||
// Barcode
|
||||
if (discogsRelease.identifiers) {
|
||||
$.each(discogsRelease.identifiers, function(index, identifier) {
|
||||
$.each(discogsRelease.identifiers, function (index, identifier) {
|
||||
if (identifier.type == 'Barcode') {
|
||||
release.barcode = identifier.value.replace(/ /g, '');
|
||||
return false;
|
||||
|
@ -593,7 +587,7 @@ function parseDiscogsRelease(data) {
|
|||
let heading = '';
|
||||
let releaseNumber = 1;
|
||||
let lastPosition = 0;
|
||||
$.each(discogsRelease.tracklist, function(index, discogsTrack) {
|
||||
$.each(discogsRelease.tracklist, function (index, discogsTrack) {
|
||||
if (discogsTrack.type_ == 'heading') {
|
||||
heading = discogsTrack.title;
|
||||
return;
|
||||
|
@ -610,12 +604,12 @@ function parseDiscogsRelease(data) {
|
|||
// Track artist credit
|
||||
track.artist_credit = [];
|
||||
if (discogsTrack.artists) {
|
||||
$.each(discogsTrack.artists, function(index, artist) {
|
||||
$.each(discogsTrack.artists, function (index, artist) {
|
||||
let ac = {
|
||||
artist_name: artistNoNum(artist.name),
|
||||
credited_name: artist.anv != '' ? artist.anv : artistNoNum(artist.name),
|
||||
joinphrase: decodeDiscogsJoinphrase(artist.join),
|
||||
mbid: MBIDfromUrl(artist.resource_url, 'artist')
|
||||
mbid: MBIDfromUrl(artist.resource_url, 'artist'),
|
||||
};
|
||||
track.artist_credit.push(ac);
|
||||
});
|
||||
|
@ -631,7 +625,7 @@ function parseDiscogsRelease(data) {
|
|||
// Append titles of sub-tracks to main track title
|
||||
let subtrack_titles = [];
|
||||
let subtrack_total_duration = 0;
|
||||
$.each(discogsTrack.sub_tracks, function(subtrack_index, subtrack) {
|
||||
$.each(discogsTrack.sub_tracks, function (subtrack_index, subtrack) {
|
||||
if (subtrack.type_ != 'track') {
|
||||
return;
|
||||
}
|
||||
|
@ -712,7 +706,7 @@ function parseDiscogsRelease(data) {
|
|||
if (!release.discs[discindex]) {
|
||||
let newdisc = {
|
||||
tracks: [],
|
||||
format: release_formats[discindex]
|
||||
format: release_formats[discindex],
|
||||
};
|
||||
if (heading) {
|
||||
newdisc.title = heading;
|
||||
|
@ -811,7 +805,7 @@ var MediaTypes = {
|
|||
'Vinyl7"': '7" Vinyl',
|
||||
'Vinyl10"': '10" Vinyl',
|
||||
'Vinyl12"': '12" Vinyl',
|
||||
'Lathe Cut': 'Phonograph record'
|
||||
'Lathe Cut': 'Phonograph record',
|
||||
};
|
||||
|
||||
var Countries = {
|
||||
|
@ -1071,5 +1065,5 @@ var Countries = {
|
|||
'Iran, Islamic Republic of': 'IR',
|
||||
'Saint Pierre and Miquelon': 'PM',
|
||||
'Saint Helena': 'SH',
|
||||
'Svalbard and Jan Mayen': 'SJ'
|
||||
'Svalbard and Jan Mayen': 'SJ',
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
var mblinks = new MBLinks('ENCYLOPEDISQUE_MBLINKS_CACHE');
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
|
||||
if (window.location.href.match(/encyclopedisque\.fr\/disque\/(\d+)/)) {
|
||||
|
@ -47,31 +47,31 @@ function setupImportUI(release) {
|
|||
function insertMBLinks() {
|
||||
let current_url = window.location.href;
|
||||
if (current_url.match(/\/disque\//)) {
|
||||
mblinks.searchAndDisplayMbLink(current_url, 'release', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(current_url, 'release', function (link) {
|
||||
$('h2 span').before(link);
|
||||
});
|
||||
} else if (current_url.match(/\/artiste\//)) {
|
||||
mblinks.searchAndDisplayMbLink(current_url, 'artist', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(current_url, 'artist', function (link) {
|
||||
$('h2').prepend(link);
|
||||
});
|
||||
}
|
||||
|
||||
$('div.v7P, div.v12P')
|
||||
.find('a[href*="/disque/"]')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let $link = $(this);
|
||||
let external_url = window.location.origin + $link.attr('href');
|
||||
mblinks.searchAndDisplayMbLink(external_url, 'release', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(external_url, 'release', function (link) {
|
||||
$link.after(link).after('<br />');
|
||||
});
|
||||
});
|
||||
|
||||
$('h2, div.main')
|
||||
.find('a[href*="/artiste/"]')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let $link = $(this);
|
||||
let external_url = window.location.origin + $link.attr('href');
|
||||
mblinks.searchAndDisplayMbLink(external_url, 'artist', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(external_url, 'artist', function (link) {
|
||||
$link.before(link);
|
||||
});
|
||||
});
|
||||
|
@ -162,7 +162,7 @@ function parseEncyclopedisquePage() {
|
|||
release.labels = [];
|
||||
let labels = m[3];
|
||||
if (labels != undefined) {
|
||||
$.each(labels.split('/'), function(index, label) {
|
||||
$.each(labels.split('/'), function (index, label) {
|
||||
release.labels.push({ name: label.trim(), catno: m[4] });
|
||||
});
|
||||
} else {
|
||||
|
@ -213,7 +213,7 @@ function parseEncyclopedisquePage() {
|
|||
// Format => medium format, release-group type, release status
|
||||
var infoValue = releaseInfos[i].querySelector('td:nth-of-type(2)').textContent.trim();
|
||||
let values = infoValue.split(' / ');
|
||||
values.forEach(function(value) {
|
||||
values.forEach(function (value) {
|
||||
if (value.indexOf('45 tours') > -1) {
|
||||
disc.format = '7" Vinyl';
|
||||
}
|
||||
|
|
|
@ -58,14 +58,14 @@ function inject_release_group_button(parent) {
|
|||
|
||||
let button = create_button(
|
||||
`/ws/2/release?release-group=${mbid}&limit=100&inc=media&fmt=json`,
|
||||
function(toggled) {
|
||||
function (toggled) {
|
||||
if (toggled) parent.appendChild(table);
|
||||
else parent.removeChild(table);
|
||||
},
|
||||
function(json) {
|
||||
function (json) {
|
||||
parse_release_group(json, mbid, parent, table);
|
||||
},
|
||||
function(status) {
|
||||
function (status) {
|
||||
table.innerHTML = `<tr><td style="color: #f00;">Error loading release group (HTTP status ${status})</td></tr>`;
|
||||
}
|
||||
);
|
||||
|
@ -83,14 +83,14 @@ function inject_release_button(parent, _table_parent, _table, _mbid) {
|
|||
|
||||
let button = create_button(
|
||||
`/ws/2/release/${mbid}?inc=media+recordings+artist-credits&fmt=json`,
|
||||
function(toggled) {
|
||||
function (toggled) {
|
||||
if (toggled) parent.appendChild(table);
|
||||
else parent.removeChild(table);
|
||||
},
|
||||
function(json) {
|
||||
function (json) {
|
||||
parse_release(json, table);
|
||||
},
|
||||
function(status) {
|
||||
function (status) {
|
||||
table.innerHTML = `<tr><td style="color: #f00;">Error loading release (HTTP status ${status})</td></tr>`;
|
||||
}
|
||||
);
|
||||
|
@ -109,7 +109,7 @@ function create_button(url, dom_callback, success_callback, error_callback) {
|
|||
|
||||
button.addEventListener(
|
||||
'mousedown',
|
||||
function() {
|
||||
function () {
|
||||
toggled = !toggled;
|
||||
if (toggled) button.innerHTML = '▼';
|
||||
else button.innerHTML = '▶';
|
||||
|
@ -120,12 +120,12 @@ function create_button(url, dom_callback, success_callback, error_callback) {
|
|||
|
||||
button.addEventListener(
|
||||
'mousedown',
|
||||
function() {
|
||||
function () {
|
||||
let this_event = arguments.callee;
|
||||
button.removeEventListener('mousedown', this_event, false);
|
||||
let req = new XMLHttpRequest();
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState != 4) return;
|
||||
|
||||
if (req.status == 200 && req.responseText) {
|
||||
|
@ -133,7 +133,7 @@ function create_button(url, dom_callback, success_callback, error_callback) {
|
|||
} else {
|
||||
button.addEventListener(
|
||||
'mousedown',
|
||||
function() {
|
||||
function () {
|
||||
button.removeEventListener('mousedown', arguments.callee, false);
|
||||
button.addEventListener('mousedown', this_event, false);
|
||||
},
|
||||
|
@ -187,14 +187,14 @@ function parse_release_group(json, mbid, parent, table) {
|
|||
release.formats = formats.join(' + ');
|
||||
}
|
||||
|
||||
releases.sort(function(a, b) {
|
||||
releases.sort(function (a, b) {
|
||||
if (a.date < b.date) return -1;
|
||||
if (a.date > b.date) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (var i = 0; i < releases.length; i++) {
|
||||
(function(release) {
|
||||
(function (release) {
|
||||
let track_tr = document.createElement('tr'),
|
||||
track_td = document.createElement('td'),
|
||||
track_table = document.createElement('table'),
|
||||
|
|
|
@ -77,7 +77,7 @@ function fastCancelScript() {
|
|||
background: '#FFBA58',
|
||||
'border-top': '1px #000 solid',
|
||||
'border-left': '1px #000 solid',
|
||||
padding: '0.5em'
|
||||
padding: '0.5em',
|
||||
})
|
||||
.appendTo('body')
|
||||
.hide();
|
||||
|
@ -90,7 +90,7 @@ function fastCancelScript() {
|
|||
}
|
||||
}
|
||||
|
||||
document.body.addEventListener('click', function(event) {
|
||||
document.body.addEventListener('click', function (event) {
|
||||
if (event.target && event.target.tagName && event.target.tagName == 'A' && event.target.classList.contains('negative')) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
@ -100,7 +100,7 @@ function fastCancelScript() {
|
|||
let $self = $(event.target),
|
||||
$edit = $self.parents('div.edit-list:eq(0)');
|
||||
|
||||
pushRequest(function() {
|
||||
pushRequest(function () {
|
||||
let editNote = $edit.find('div.add-edit-note textarea').val();
|
||||
let data = { 'confirm.edit_note': editNote };
|
||||
|
||||
|
@ -108,35 +108,35 @@ function fastCancelScript() {
|
|||
type: 'POST',
|
||||
url: $self.attr('href'),
|
||||
data: data,
|
||||
error: function(request, status, error) {
|
||||
error: function (request, status, error) {
|
||||
$self
|
||||
.css({
|
||||
background: 'red',
|
||||
color: 'yellow',
|
||||
cursor: 'help'
|
||||
cursor: 'help',
|
||||
})
|
||||
.attr('title', `Error cancelling this edit: “${error}”`);
|
||||
$edit.css({ border: '6px solid red' }).show();
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
$edit.remove();
|
||||
totalCancels -= 1;
|
||||
updateStatus();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
$edit.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("div#edits > form[action$='/edit/enter_votes']").on('submit', function(event) {
|
||||
$("div#edits > form[action$='/edit/enter_votes']").on('submit', function (event) {
|
||||
if (totalCancels > 0) {
|
||||
event.preventDefault();
|
||||
alert(`Please wait, ${totalCancels > 1 ? `${totalCancels} edits are` : 'an edit is'} being cancelled in the background.`);
|
||||
}
|
||||
});
|
||||
|
||||
var pushRequest = (function() {
|
||||
var pushRequest = (function () {
|
||||
let queue = [],
|
||||
last = 0,
|
||||
active = false,
|
||||
|
@ -152,7 +152,7 @@ function fastCancelScript() {
|
|||
}
|
||||
}
|
||||
|
||||
return function(req) {
|
||||
return function (req) {
|
||||
queue.push(req);
|
||||
|
||||
if (!active) {
|
||||
|
|
|
@ -48,13 +48,13 @@ var release_attributes = {}; // albumid, total_pages, artist_name, label
|
|||
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() {
|
||||
$(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() {
|
||||
$('#api_key_submit').click(function () {
|
||||
let myval = $('#apikey_input').val();
|
||||
localStorage.setItem('FMA_API_KEY', myval);
|
||||
$('#musicbrainz_apikey').hide();
|
||||
|
@ -87,7 +87,7 @@ $(document).ready(function() {
|
|||
|
||||
// Track detail
|
||||
$.when(retrieve_track_info) // ensure the track info is retrieved first (total_pages counter)
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
// loop and deferred promise for multiple ajax calls
|
||||
updateAPISection.TrackAjaxStatus('busy');
|
||||
let track_api_calls = [];
|
||||
|
@ -95,25 +95,25 @@ $(document).ready(function() {
|
|||
track_api_calls.push(track_api(i));
|
||||
}
|
||||
|
||||
$.when.apply(this, track_api_calls).done(function() {
|
||||
$.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() {
|
||||
.done(function () {
|
||||
LOGGER.debug('Deferred for: Track info > track detail > resolved');
|
||||
});
|
||||
|
||||
$.when(retrieve_tracks_promise)
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
updateAPISection.TrackAjaxStatus('completed');
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
updateAPISection.TrackAjaxStatus('fail');
|
||||
});
|
||||
|
||||
$.when(retrieve_track_info, retrieve_tracks_promise, retrieve_album_detail).done(function() {
|
||||
$.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);
|
||||
|
@ -123,17 +123,15 @@ $(document).ready(function() {
|
|||
|
||||
let album_link = window.location.href;
|
||||
|
||||
let url = $(location)
|
||||
.attr('href')
|
||||
.split('/');
|
||||
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) {
|
||||
mblinks.searchAndDisplayMbLink(album_link, 'release', function (link) {
|
||||
$('.subh1').before(link);
|
||||
});
|
||||
mblinks.searchAndDisplayMbLink(artist_link, 'artist', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(artist_link, 'artist', function (link) {
|
||||
$('.subh1').after(link);
|
||||
});
|
||||
});
|
||||
|
@ -169,7 +167,7 @@ function insertAPISection() {
|
|||
|
||||
if (DEBUG)
|
||||
fmaUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let fmaStatusBlock = $(
|
||||
|
@ -183,7 +181,7 @@ function insertAPISection() {
|
|||
display: 'inline-block',
|
||||
float: 'left',
|
||||
height: '120px',
|
||||
width: '49%'
|
||||
width: '49%',
|
||||
});
|
||||
|
||||
fmaUI.slideDown();
|
||||
|
@ -191,17 +189,17 @@ function insertAPISection() {
|
|||
|
||||
// Update FreeMusicArchive API Status section on FMA page
|
||||
var updateAPISection = {
|
||||
AlbumId: function(albumid) {
|
||||
AlbumId: function (albumid) {
|
||||
this.albumid = albumid;
|
||||
$('#lbut-lt-fma-api-album-id').text(this.albumid);
|
||||
return 'complete';
|
||||
},
|
||||
ApiKey: function(apikey) {
|
||||
ApiKey: function (apikey) {
|
||||
this.apikey = apikey;
|
||||
$('#lbut-lt-fma-api-key-id').text(FMA_API);
|
||||
return 'complete';
|
||||
},
|
||||
AlbumAjaxStatus: function(ajaxstatus) {
|
||||
AlbumAjaxStatus: function (ajaxstatus) {
|
||||
if (ajaxstatus === null) {
|
||||
this.ajaxstatus = 'notcalled';
|
||||
} else {
|
||||
|
@ -212,24 +210,24 @@ var updateAPISection = {
|
|||
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'
|
||||
'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'
|
||||
'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'
|
||||
'background-color': 'red',
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
TrackAjaxStatus: function(ajaxstatus) {
|
||||
TrackAjaxStatus: function (ajaxstatus) {
|
||||
if (ajaxstatus === null) {
|
||||
this.ajaxstatus = 'notcalled';
|
||||
} else {
|
||||
|
@ -240,23 +238,23 @@ var updateAPISection = {
|
|||
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'
|
||||
'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'
|
||||
'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'
|
||||
'background-color': 'red',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Insert MusicBrainz section on FMA page
|
||||
|
@ -268,7 +266,7 @@ function insertMBSection(release) {
|
|||
).hide();
|
||||
if (DEBUG)
|
||||
mbUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let mbContentBlock = $('<div class="section_content"></div>');
|
||||
|
@ -279,7 +277,7 @@ function insertMBSection(release) {
|
|||
color: 'red',
|
||||
float: 'left',
|
||||
'margin-top': '4px',
|
||||
'margin-bottom': '4px'
|
||||
'margin-bottom': '4px',
|
||||
});
|
||||
mbContentBlock.prepend(warning_buggy);
|
||||
}
|
||||
|
@ -300,25 +298,25 @@ function insertMBSection(release) {
|
|||
display: 'block',
|
||||
float: 'right',
|
||||
height: '120px',
|
||||
width: '49%'
|
||||
width: '49%',
|
||||
});
|
||||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
float: 'right',
|
||||
height: '80px'
|
||||
height: '80px',
|
||||
});
|
||||
$('form.musicbrainz_import').css({
|
||||
width: '49%',
|
||||
display: 'inline-block'
|
||||
display: 'inline-block',
|
||||
});
|
||||
$('form.musicbrainz_import_search').css({
|
||||
float: 'right'
|
||||
float: 'right',
|
||||
});
|
||||
$('form.musicbrainz_import > button').css({
|
||||
width: '63px',
|
||||
height: '80px',
|
||||
'box-sizing': 'border-box'
|
||||
'box-sizing': 'border-box',
|
||||
});
|
||||
|
||||
mbUI.slideDown();
|
||||
|
@ -333,7 +331,7 @@ function insertAPIKEYSection() {
|
|||
).hide();
|
||||
if (DEBUG)
|
||||
mbUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let mbContentBlock = $('<div class="section_content"></div>');
|
||||
|
@ -351,13 +349,13 @@ function insertAPIKEYSection() {
|
|||
display: 'block',
|
||||
float: 'right',
|
||||
height: '120px',
|
||||
width: '49%'
|
||||
width: '49%',
|
||||
});
|
||||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
float: 'right',
|
||||
height: '80px'
|
||||
height: '80px',
|
||||
});
|
||||
|
||||
mbUI.slideDown();
|
||||
|
@ -371,10 +369,10 @@ function insertAPIKEYSection() {
|
|||
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() {
|
||||
var promise_variable = $.getJSON(fmaWsUrl, function () {
|
||||
updateAPISection.AlbumAjaxStatus('busy');
|
||||
LOGGER.debug(`promise_variable [state] in [getJSON] ${promise_variable.state()}`);
|
||||
}).done(function(albumjson) {
|
||||
}).done(function (albumjson) {
|
||||
LOGGER.debug(' >> Album > DONE');
|
||||
updateAPISection.AlbumAjaxStatus('completed');
|
||||
//LOGGER.debug(albumjson);
|
||||
|
@ -389,9 +387,9 @@ function album_api() {
|
|||
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() {
|
||||
var promise_track_api_params = $.getJSON(fmaWsUrl, function () {
|
||||
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api_params.state()}`);
|
||||
}).done(function(trackinfojson) {
|
||||
}).done(function (trackinfojson) {
|
||||
LOGGER.debug(' >> Track INFO > DONE');
|
||||
release_attributes.total_pages = trackinfojson.total_pages;
|
||||
//LOGGER.debug(trackinfojson);
|
||||
|
@ -406,9 +404,9 @@ function track_api(page) {
|
|||
release_attributes.albumid
|
||||
}&limit=20&page=${parseInt(page)}`;
|
||||
|
||||
var promise_track_api = $.getJSON(fmaWsUrl, function() {
|
||||
var promise_track_api = $.getJSON(fmaWsUrl, function () {
|
||||
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api.state()}`);
|
||||
}).done(function(tracksjson) {
|
||||
}).done(function (tracksjson) {
|
||||
LOGGER.debug(` >> Track page ${page} > DONE `);
|
||||
LOGGER.debug(tracksjson);
|
||||
tracks_api_array.push(tracksjson.dataset);
|
||||
|
@ -446,17 +444,11 @@ function parseFMApage() {
|
|||
}
|
||||
|
||||
// Label parsed from webpage as it is not in API
|
||||
$('div.sbar-stat span.lf105.stathd').each(function() {
|
||||
$('div.sbar-stat span.lf105.stathd').each(function () {
|
||||
//var tester = $(this).eq(0).text().trim().toLowerCase(); // working
|
||||
let taglist = $(this)
|
||||
.eq(0)
|
||||
.text()
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
let taglist = $(this).eq(0).text().trim().toLowerCase();
|
||||
if (taglist == 'label:') {
|
||||
release_attributes.label = $(this)
|
||||
.next()
|
||||
.text();
|
||||
release_attributes.label = $(this).next().text();
|
||||
// fmarelease.labels.push({
|
||||
// name: FMAAlbumLabel
|
||||
// });
|
||||
|
@ -473,7 +465,7 @@ function parseFMApage() {
|
|||
// 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) {
|
||||
let m = date.split(/\D+/, 3).map(function (e) {
|
||||
return parseInt(e, 10);
|
||||
});
|
||||
if (m[0] !== undefined) {
|
||||
|
@ -557,13 +549,13 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
// Release URL
|
||||
fmarelease.urls.push({
|
||||
url: albumobject.album_url,
|
||||
link_type: MBImport.URL_TYPES.download_for_free
|
||||
link_type: MBImport.URL_TYPES.download_for_free,
|
||||
});
|
||||
} else {
|
||||
// Release URL
|
||||
fmarelease.urls.push({
|
||||
url: albumobject.album_url,
|
||||
link_type: MBImport.URL_TYPES.other_databases
|
||||
link_type: MBImport.URL_TYPES.other_databases,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -572,7 +564,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
// Release URL
|
||||
fmarelease.urls.push({
|
||||
url: albumobject.album_url,
|
||||
link_type: MBImport.URL_TYPES.stream_for_free
|
||||
link_type: MBImport.URL_TYPES.stream_for_free,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -583,7 +575,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
|
||||
// Label parsed from webpage as it is not in API
|
||||
fmarelease.labels.push({
|
||||
name: release_attributes.label
|
||||
name: release_attributes.label,
|
||||
});
|
||||
|
||||
let discarray = [];
|
||||
|
@ -612,7 +604,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
// Could not find a example where disc_number != 1 yet but started teh check so long
|
||||
let largest_disc = Math.max.apply(
|
||||
Math,
|
||||
trackarray.map(function(o) {
|
||||
trackarray.map(function (o) {
|
||||
return o.disc_number;
|
||||
})
|
||||
);
|
||||
|
@ -620,14 +612,14 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
|
||||
for (var 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) {
|
||||
let tracklist_per_disc = $.map(trackarray, function (obj, index) {
|
||||
if (obj.disc_number == disccount) {
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
|
||||
// use this to sort the tracks per disc from low to high
|
||||
tracklist_per_disc = tracklist_per_disc.sort(function(a, b) {
|
||||
tracklist_per_disc = tracklist_per_disc.sort(function (a, b) {
|
||||
return parseInt(a.number) - parseInt(b.number);
|
||||
});
|
||||
|
||||
|
@ -646,7 +638,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
let disc = {
|
||||
position: disccount,
|
||||
format: 'Digital Media',
|
||||
tracks: tracklist_per_disc
|
||||
tracks: tracklist_per_disc,
|
||||
};
|
||||
fmarelease.discs.push(disc);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
let releaseUrl = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
|
||||
let release = retrieveReleaseInfo(releaseUrl);
|
||||
|
@ -37,7 +37,7 @@ function parseReleaseDate(rdate) {
|
|||
September: 9,
|
||||
October: 10,
|
||||
November: 11,
|
||||
December: 12
|
||||
December: 12,
|
||||
};
|
||||
|
||||
let m = rdate.match(/(\d{1,2}) ([a-z]+), (\d{4})/i);
|
||||
|
@ -45,7 +45,7 @@ function parseReleaseDate(rdate) {
|
|||
return {
|
||||
year: m[3],
|
||||
month: months[m[2]],
|
||||
day: m[1]
|
||||
day: m[1],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,7 @@ function parseReleaseDate(rdate) {
|
|||
function retrieveReleaseInfo(release_url) {
|
||||
let release = {
|
||||
artist_credit: [],
|
||||
title: $('meta[itemProp="name"]')
|
||||
.attr('content')
|
||||
.trim(),
|
||||
title: $('meta[itemProp="name"]').attr('content').trim(),
|
||||
year: 0,
|
||||
month: 0,
|
||||
day: 0,
|
||||
|
@ -70,14 +68,10 @@ function retrieveReleaseInfo(release_url) {
|
|||
type: '',
|
||||
urls: [],
|
||||
labels: [],
|
||||
discs: []
|
||||
discs: [],
|
||||
};
|
||||
|
||||
let releaseDate = parseReleaseDate(
|
||||
$('span[itemProp="datePublished"]')
|
||||
.text()
|
||||
.trim()
|
||||
);
|
||||
let releaseDate = parseReleaseDate($('span[itemProp="datePublished"]').text().trim());
|
||||
|
||||
if (releaseDate) {
|
||||
release.year = releaseDate.year;
|
||||
|
@ -87,54 +81,36 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download,
|
||||
});
|
||||
|
||||
release.labels.push({
|
||||
name: $('meta[itemProp="author"]')
|
||||
.attr('content')
|
||||
.trim(),
|
||||
catno: $('strong:contains("Cat:")')
|
||||
.parent()
|
||||
.contents()
|
||||
.slice(2, 3)
|
||||
.text()
|
||||
.trim()
|
||||
name: $('meta[itemProp="author"]').attr('content').trim(),
|
||||
catno: $('strong:contains("Cat:")').parent().contents().slice(2, 3).text().trim(),
|
||||
});
|
||||
|
||||
let tracks = [];
|
||||
$('.product-tracklist-track[itemprop="track"]').each(function() {
|
||||
$('.product-tracklist-track[itemprop="track"]').each(function () {
|
||||
// element only present if VA release or track has multiple artists
|
||||
let artist = $(this)
|
||||
.find('meta[itemprop="byArtist"]')
|
||||
.attr('content');
|
||||
let artist = $(this).find('meta[itemprop="byArtist"]').attr('content');
|
||||
if (artist !== undefined) {
|
||||
artist = artist.trim();
|
||||
}
|
||||
let trackname = $(this)
|
||||
.find('span[itemprop="name"]')
|
||||
.text()
|
||||
.trim();
|
||||
let tracklength = $(this)
|
||||
.find('meta[itemprop="duration"]')
|
||||
.parent()
|
||||
.contents()
|
||||
.slice(0, 1)
|
||||
.text()
|
||||
.trim();
|
||||
let trackname = $(this).find('span[itemprop="name"]').text().trim();
|
||||
let tracklength = $(this).find('meta[itemprop="duration"]').parent().contents().slice(0, 1).text().trim();
|
||||
if (artist !== undefined && trackname.startsWith(`${artist} - `)) {
|
||||
trackname = trackname.replace(`${artist} - `, '');
|
||||
}
|
||||
tracks.push({
|
||||
artist_credit: MBImport.makeArtistCredits(artist === undefined ? [] : [artist]),
|
||||
title: trackname,
|
||||
duration: tracklength
|
||||
duration: tracklength,
|
||||
});
|
||||
});
|
||||
|
||||
let releaseArtists = $('.product-artist')
|
||||
.contents()
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
if (this.nodeType === Node.TEXT_NODE) {
|
||||
return this.nodeValue === ' / ' ? null : this.nodeValue;
|
||||
} else {
|
||||
|
@ -151,7 +127,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: release.format
|
||||
format: release.format,
|
||||
});
|
||||
|
||||
LOGGER.info('Parsed release: ', release);
|
||||
|
@ -168,9 +144,7 @@ function insertLink(release, releaseUrl) {
|
|||
)}</div></div>`
|
||||
).hide();
|
||||
|
||||
$('.product-share')
|
||||
.parent()
|
||||
.after(mbUI);
|
||||
$('.product-share').parent().after(mbUI);
|
||||
$('#mb_buttons form').css({ display: 'inline', 'margin-right': '5px' });
|
||||
mbUI.slideDown();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Logger
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var LOGGER = (function() {
|
||||
var LOGGER = (function () {
|
||||
let LOG_LEVEL = 'info';
|
||||
|
||||
function fnDebug() {
|
||||
|
@ -44,6 +44,6 @@ var LOGGER = (function() {
|
|||
debug: fnDebug,
|
||||
info: fnInfo,
|
||||
error: fnError,
|
||||
setLevel: fnSetLevel
|
||||
setLevel: fnSetLevel,
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -58,18 +58,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var MBImport = (function() {
|
||||
var MBImport = (function () {
|
||||
// --------------------------------------- publics ----------------------------------------- //
|
||||
|
||||
let special_artists = {
|
||||
various_artists: {
|
||||
name: 'Various Artists',
|
||||
mbid: '89ad4ac3-39f7-470e-963a-56509c546377'
|
||||
mbid: '89ad4ac3-39f7-470e-963a-56509c546377',
|
||||
},
|
||||
unknown: {
|
||||
name: '[unknown]',
|
||||
mbid: '125ec42a-7229-4250-afc5-e057484327fe'
|
||||
}
|
||||
mbid: '125ec42a-7229-4250-afc5-e057484327fe',
|
||||
},
|
||||
};
|
||||
|
||||
let url_types = {
|
||||
|
@ -79,7 +79,7 @@ var MBImport = (function() {
|
|||
purchase_for_mail_order: 79,
|
||||
other_databases: 82,
|
||||
stream_for_free: 85,
|
||||
license: 301
|
||||
license: 301,
|
||||
};
|
||||
|
||||
function fnSpecialArtist(key, ac) {
|
||||
|
@ -92,7 +92,7 @@ var MBImport = (function() {
|
|||
artist_name: special_artists[key].name,
|
||||
credited_name: credited_name,
|
||||
joinphrase: joinphrase,
|
||||
mbid: special_artists[key].mbid
|
||||
mbid: special_artists[key].mbid,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ var MBImport = (function() {
|
|||
function fnBuildSearchLink(release) {
|
||||
let parameters = searchParams(release);
|
||||
let url_params = [];
|
||||
parameters.forEach(function(parameter) {
|
||||
parameters.forEach(function (parameter) {
|
||||
let value = `${parameter.value}`;
|
||||
url_params.push(encodeURI(`${parameter.name}=${value}`));
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ var MBImport = (function() {
|
|||
function fnBuildSearchButton(release) {
|
||||
let parameters = searchParams(release);
|
||||
let html = `<form class="musicbrainz_import musicbrainz_import_search" action="//musicbrainz.org/search" method="get" target="_blank" accept-charset="UTF-8" charset="${document.characterSet}">`;
|
||||
parameters.forEach(function(parameter) {
|
||||
parameters.forEach(function (parameter) {
|
||||
let value = `${parameter.value}`;
|
||||
html += `<input type='hidden' value='${value.replace(/'/g, ''')}' name='${parameter.name}'/>`;
|
||||
});
|
||||
|
@ -131,7 +131,7 @@ var MBImport = (function() {
|
|||
function fnBuildFormHTML(parameters) {
|
||||
// Build form
|
||||
let innerHTML = `<form class="musicbrainz_import musicbrainz_import_add" action="//musicbrainz.org/release/add" method="post" target="_blank" accept-charset="UTF-8" charset="${document.characterSet}">`;
|
||||
parameters.forEach(function(parameter) {
|
||||
parameters.forEach(function (parameter) {
|
||||
let value = `${parameter.value}`;
|
||||
innerHTML += `<input type='hidden' value='${value.replace(/'/g, ''')}' name='${parameter.name}'/>`;
|
||||
});
|
||||
|
@ -242,7 +242,7 @@ var MBImport = (function() {
|
|||
|
||||
// Convert a list of artists to a list of artist credits with joinphrases
|
||||
function fnArtistCredits(artists_list) {
|
||||
let artists = artists_list.map(function(item) {
|
||||
let artists = artists_list.map(function (item) {
|
||||
return { artist_name: item };
|
||||
});
|
||||
if (artists.length > 2) {
|
||||
|
@ -260,7 +260,7 @@ var MBImport = (function() {
|
|||
}
|
||||
let credits = [];
|
||||
// re-split artists if featuring or vs
|
||||
artists.map(function(item) {
|
||||
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*\b(?:versus|vs\.?)\s+/gi, ' vs. ');
|
||||
|
@ -277,12 +277,12 @@ var MBImport = (function() {
|
|||
} else {
|
||||
new_items[n++] = {
|
||||
artist_name: splitted[i].trim(),
|
||||
joinphrase: ''
|
||||
joinphrase: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
new_items[n - 1].joinphrase = item.joinphrase;
|
||||
new_items.map(function(newit) {
|
||||
new_items.map(function (newit) {
|
||||
credits.push(newit);
|
||||
});
|
||||
}
|
||||
|
@ -411,6 +411,6 @@ var MBImport = (function() {
|
|||
searchUrlFor: fnSearchUrlFor,
|
||||
URL_TYPES: url_types,
|
||||
SPECIAL_ARTISTS: special_artists,
|
||||
specialArtist: fnSpecialArtist
|
||||
specialArtist: fnSpecialArtist,
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
// 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
|
||||
var MBLinks = function(user_cache_key, version, expiration) {
|
||||
this.supports_local_storage = (function() {
|
||||
var MBLinks = function (user_cache_key, version, expiration) {
|
||||
this.supports_local_storage = (function () {
|
||||
try {
|
||||
return !!localStorage.getItem;
|
||||
} catch (e) {
|
||||
|
@ -29,10 +29,10 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
// properties: "key": {handler: function, next: property, context: {}}
|
||||
first: '',
|
||||
last: '',
|
||||
empty: function() {
|
||||
empty: function () {
|
||||
return this.first == '';
|
||||
},
|
||||
push: function(key, handler, context) {
|
||||
push: function (key, handler, context) {
|
||||
if (key in this) {
|
||||
this[key].handler = handler;
|
||||
this[key].context = context;
|
||||
|
@ -46,7 +46,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
}
|
||||
}
|
||||
},
|
||||
shift: function() {
|
||||
shift: function () {
|
||||
if (this.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
this.first = this[key].next;
|
||||
delete this[key]; // delete this property
|
||||
return $.proxy(handler, context);
|
||||
}
|
||||
},
|
||||
};
|
||||
this.cache = {};
|
||||
this.expirationMinutes = typeof expiration != 'undefined' && expiration !== false ? parseInt(expiration, 10) : 90 * 24 * 60; // default to 90 days
|
||||
|
@ -67,16 +67,16 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
// overrides link title and img src url (per type), see createMusicBrainzLink()
|
||||
this.type_link_info = {
|
||||
release_group: {
|
||||
title: 'See this release group on MusicBrainz'
|
||||
title: 'See this release group on MusicBrainz',
|
||||
},
|
||||
place: {
|
||||
img_src: `<img src="${this.mb_server}/static/images/entity/place.svg" height=16 width=16 />`
|
||||
}
|
||||
img_src: `<img src="${this.mb_server}/static/images/entity/place.svg" height=16 width=16 />`,
|
||||
},
|
||||
};
|
||||
|
||||
this.initAjaxEngine = function() {
|
||||
this.initAjaxEngine = function () {
|
||||
let ajax_requests = this.ajax_requests;
|
||||
setInterval(function() {
|
||||
setInterval(function () {
|
||||
if (!ajax_requests.empty()) {
|
||||
let request = ajax_requests.shift();
|
||||
if (typeof request === 'function') {
|
||||
|
@ -86,7 +86,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
}, 1000);
|
||||
};
|
||||
|
||||
this.initCache = function() {
|
||||
this.initCache = function () {
|
||||
if (!this.supports_local_storage) return;
|
||||
// Check if we already added links for this content
|
||||
this.cache = JSON.parse(localStorage.getItem(this.cache_key) || '{}');
|
||||
|
@ -96,7 +96,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
this.removeOldCacheVersions();
|
||||
};
|
||||
|
||||
this.saveCache = function() {
|
||||
this.saveCache = function () {
|
||||
if (!this.supports_local_storage) return;
|
||||
try {
|
||||
localStorage.setItem(this.cache_key, JSON.stringify(this.cache));
|
||||
|
@ -105,7 +105,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
}
|
||||
};
|
||||
|
||||
this.removeOldCacheVersions = function() {
|
||||
this.removeOldCacheVersions = function () {
|
||||
let to_remove = [];
|
||||
for (var i = 0, len = localStorage.length; i < len; ++i) {
|
||||
let key = localStorage.key(i);
|
||||
|
@ -122,13 +122,13 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
}
|
||||
};
|
||||
|
||||
this.clearCacheExpired = function() {
|
||||
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, value) {
|
||||
if (that.is_cached(key)) {
|
||||
new_cache[key] = that.cache[key];
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
this.cache = new_cache;
|
||||
};
|
||||
|
||||
this.is_cached = function(key) {
|
||||
this.is_cached = function (key) {
|
||||
return (
|
||||
this.cache[key] &&
|
||||
this.expirationMinutes > 0 &&
|
||||
|
@ -148,13 +148,13 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
|
||||
// Search for ressource 'url' in local cache, and return the matching MBID if there's only matching MB entity.
|
||||
// If the url is not known by the cache, no attempt will be made to request the MusicBrainz webservice, in order to keep this method synchronous.
|
||||
this.resolveMBID = function(key) {
|
||||
this.resolveMBID = function (key) {
|
||||
if (this.is_cached(key) && this.cache[key].urls.length == 1) {
|
||||
return this.cache[key].urls[0].slice(-36);
|
||||
}
|
||||
};
|
||||
|
||||
this.createMusicBrainzLink = function(mb_url, _type) {
|
||||
this.createMusicBrainzLink = function (mb_url, _type) {
|
||||
let title = `See this ${_type} on MusicBrainz`;
|
||||
let img_url = `${this.mb_server}/static/images/entity/${_type}.svg`;
|
||||
let img_src = `<img src="${img_url}" height=16 width=16 />`;
|
||||
|
@ -171,13 +171,13 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
// Search for ressource 'url' on MB, for relation of type 'mb_type' (artist, release, label, release-group, ...)
|
||||
// and call 'insert_func' function with matching MB links (a tag built in createMusicBrainzLink) for each
|
||||
// entry found
|
||||
this.searchAndDisplayMbLink = function(url, mb_type, insert_func, key) {
|
||||
this.searchAndDisplayMbLink = function (url, mb_type, insert_func, key) {
|
||||
let mblinks = this;
|
||||
let _type = mb_type.replace('-', '_'); // underscored type
|
||||
|
||||
if (!key) key = url;
|
||||
if (this.is_cached(key)) {
|
||||
$.each(mblinks.cache[key].urls, function(idx, mb_url) {
|
||||
$.each(mblinks.cache[key].urls, function (idx, mb_url) {
|
||||
insert_func(mblinks.createMusicBrainzLink(mb_url, _type));
|
||||
});
|
||||
} else {
|
||||
|
@ -196,22 +196,22 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
query,
|
||||
|
||||
// handler
|
||||
function() {
|
||||
function () {
|
||||
let ctx = this; // context from $.proxy()
|
||||
let mbl = ctx.mblinks;
|
||||
$.getJSON(ctx.query, function(data) {
|
||||
$.getJSON(ctx.query, function (data) {
|
||||
if ('relations' in data) {
|
||||
mbl.cache[ctx.key] = {
|
||||
timestamp: new Date().getTime(),
|
||||
urls: []
|
||||
urls: [],
|
||||
};
|
||||
$.each(data['relations'], function(idx, relation) {
|
||||
$.each(data['relations'], function (idx, relation) {
|
||||
if (ctx._type in relation) {
|
||||
let mb_url = `${mbl.mb_server}/${ctx.mb_type}/${relation[ctx._type]['id']}`;
|
||||
if ($.inArray(mb_url, mbl.cache[ctx.key].urls) == -1) {
|
||||
// prevent dupes
|
||||
mbl.cache[ctx.key].urls.push(mb_url);
|
||||
$.each(ctx.handlers, function(i, handler) {
|
||||
$.each(ctx.handlers, function (i, handler) {
|
||||
handler(mbl.createMusicBrainzLink(mb_url, ctx._type));
|
||||
});
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
|
|||
mb_type: mb_type, // musicbrainz type ie. release-group
|
||||
_type: _type, // musicbrainz type '-' replaced, ie. release_group
|
||||
query: query, // json request url
|
||||
mblinks: mblinks // MBLinks object
|
||||
mblinks: mblinks, // MBLinks object
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ if (DEBUG) {
|
|||
* - http://www.loot.co.za/product/bette-midler-a-gift-of-love/mhgm-3483-g060 *** NOT WORKING *** extra tab
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
LOGGER.info('Document Ready & Loot Userscript executing');
|
||||
let LootRelease = ParseLootPage();
|
||||
insertMBSection(LootRelease);
|
||||
|
@ -71,7 +71,7 @@ function insertMBSection(release) {
|
|||
|
||||
if (DEBUG)
|
||||
mbUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let mbContentBlock = $('<div class="section_content"></div>');
|
||||
|
@ -83,7 +83,7 @@ function insertMBSection(release) {
|
|||
).css({
|
||||
color: 'red',
|
||||
'margin-top': '4px',
|
||||
'margin-bottom': '4px'
|
||||
'margin-bottom': '4px',
|
||||
});
|
||||
mbContentBlock.prepend(warning_buggy);
|
||||
}
|
||||
|
@ -102,18 +102,18 @@ function insertMBSection(release) {
|
|||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
width: '100%'
|
||||
width: '100%',
|
||||
});
|
||||
$('form.musicbrainz_import').css({
|
||||
width: '49%',
|
||||
display: 'inline-block'
|
||||
display: 'inline-block',
|
||||
});
|
||||
$('form.musicbrainz_import_search').css({
|
||||
float: 'right'
|
||||
float: 'right',
|
||||
});
|
||||
$('form.musicbrainz_import > button').css({
|
||||
width: '100%',
|
||||
'box-sizing': 'border-box'
|
||||
'box-sizing': 'border-box',
|
||||
});
|
||||
|
||||
mbUI.slideDown();
|
||||
|
@ -132,14 +132,14 @@ function parseReleaseDate(rdate) {
|
|||
September: 9,
|
||||
October: 10,
|
||||
November: 11,
|
||||
December: 12
|
||||
December: 12,
|
||||
};
|
||||
|
||||
let m = rdate.match(/([a-zA-Z]+) (\d{4})/i);
|
||||
if (m) {
|
||||
return {
|
||||
year: m[2],
|
||||
month: months[m[1]]
|
||||
month: months[m[1]],
|
||||
};
|
||||
}
|
||||
return false;
|
||||
|
@ -201,26 +201,17 @@ function ParseLootPage() {
|
|||
LOGGER.debug('Release Title:', releasetitle, ' Release Artist:', releaseartist, ' Release Format:', release_format);
|
||||
|
||||
// extract all tr from table with class productDetails
|
||||
$('table.productDetails tr').each(function() {
|
||||
$('table.productDetails tr').each(function () {
|
||||
// get text from first td, trim and convert it to lowercase
|
||||
let prodinfolabellowcase = $(this)
|
||||
.children('td')
|
||||
.eq(0)
|
||||
.text()
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
let prodinfolabellowcase = $(this).children('td').eq(0).text().trim().toLowerCase();
|
||||
prodinfolabellowcase = prodinfolabellowcase.replace(/\s+/g, ''); //removing white spaces as switch isnt matching spaces for some reason
|
||||
// get test from second td, which is the corresponding value
|
||||
let value = $(this)
|
||||
.children('td')
|
||||
.eq(1)
|
||||
.text()
|
||||
.trim();
|
||||
let value = $(this).children('td').eq(1).text().trim();
|
||||
// now compare and process
|
||||
switch (prodinfolabellowcase) {
|
||||
case 'label:': // use these cases to select the spesific text values
|
||||
prodlabels.push({
|
||||
name: value
|
||||
name: value,
|
||||
});
|
||||
break;
|
||||
case 'releasedate:':
|
||||
|
@ -234,7 +225,7 @@ function ParseLootPage() {
|
|||
case 'performers:':
|
||||
LOGGER.debug(' ** performers: **', value);
|
||||
release_artist_array.push({
|
||||
name: value
|
||||
name: value,
|
||||
});
|
||||
break;
|
||||
case 'format:':
|
||||
|
@ -360,7 +351,7 @@ function ParseLootPage() {
|
|||
let disc = {
|
||||
position: l + 1,
|
||||
format: release_format,
|
||||
tracks: disclistarray[l]
|
||||
tracks: disclistarray[l],
|
||||
};
|
||||
release.discs.push(disc);
|
||||
}
|
||||
|
@ -371,7 +362,7 @@ function ParseLootPage() {
|
|||
release.urls = new Array();
|
||||
release.urls.push({
|
||||
url: window.location.href,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
|
||||
});
|
||||
|
||||
// TODO check format then change purchase medium
|
||||
|
|
|
@ -20,7 +20,7 @@ var ca_page = document.querySelector('div#content');
|
|||
|
||||
var ca_items = ca_page.querySelectorAll('div.artwork-cont');
|
||||
|
||||
ca_items.forEach(function(ca_item) {
|
||||
ca_items.forEach(function (ca_item) {
|
||||
/* Use 1200px “thumbnails” for the pop‐ups/previews */
|
||||
let popup_link = ca_item.querySelector('a.artwork-image');
|
||||
popup_link.href = popup_link.href.replace(/\.[a-z]+$/, '-1200.jpg');
|
||||
|
|
|
@ -26,7 +26,7 @@ LOGGER.setLevel('info');
|
|||
var CHECK_IMAGE =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/gD+AP7rGNSCAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAQAAAAEABcxq3DAAADKklEQVQ4y32TS2hcZRiGn/8/Z87MNNc2zczEmptO0jSXagJtXCjWhhSEXpCI4EYENy6KG8FFBYtgEbzQ4k5QqNp2VyMtJVGpRU0tGDNoQxvrmCbkMslkSJrJXM6cOef8v4ukQqX4wbP5eL/327wv/M/Em+qNeFO9ASDEwzUPrM+fP8dqOhXqeGJ/f21ddCAYCsfRyFLJvru2mvnh9mTil8am1uJLQ8ceNOhoa+XC8HfMJm81x1q63glV179oBMLVhpQYEiQKzy0VNtZWLs9OT53s6X3qrxPHX+bSyNVNgyujV8lvrDXG2vZ/7oWig64nAY0hwZCCgIRwUGBJRSGbvp6cHH91R33078ODTyNOnXqPxcRl88ibX5wuBJuP5x2BVhop2PwuBA01kn2tJo4HtxfL5DIzZ7+/8MHrOx7tcMQ3I9dwnWKvF+kfTdlVEc/10f59A0HAgMEui90xgxvTLn8u+9SYhXUnNX60smr7z7Jx3wG8UOSZhUI4spJTrGwo0lssZxVSQlOdZGrJYyzpks4qlvLBWhWMHOgb7Mfsq4PfXOvx+bwgk/WxSwrfUwRNQSgAh7oCFB3N1xNllrMK04A5V7PLMOOvCSFMgFzJl6u2Jl8Gx9XkCppSWdEWNWiPGZy9XmIs6WJKKHuasq+p3qlkOwhz9B54dnbOkorOR0yG9gZJ3fP5cNTm4J4Akws+FyfKOK5GCFAatm/T4ObmB7RWxt74k9hrC0LVtLwwmw2FwyY8323hK2iLGnz2U4lMTiHvR04IGiqLxbrS7x/np3NJozoEmcTFTLTz2U7bivTcXNSsFxWHeyyGE2XGZ7x/j7WGyhA0W3e/LU58eiY1N+0IgLc++or1VLLb6hz6MmPGe/M2NFTBzIpH3lYoX6MQhC1NkzV/p2Jp5JX6eP+vn7wxsJnEXXUVnL6T59K7J/u2tR96365oey7nVQTKnsDzNFr5hETBq3ZmbrB47cS5M2+PdTbHmJpL89+OGbv3dLc81n/kWLih+yDhnTGtEcpeXXHSUz/OJ64M3/ojMS3BUw9rI2BsIUxBsLYyEJYC1nNuqawpARrwtwDgHxTwbTT5CxY9AAAALnpUWHRjcmVhdGUtZGF0ZQAAeNozMjCw0DWw0DUyCTEwsDIyszIw0jUwtTIwAABB3gURQfNnBAAAAC56VFh0bW9kaWZ5LWRhdGUAAHjaMzIwsNA1sNA1MggxNLMyNLYyNtM1MLUyMAAAQgUFF56jVzIAAAAASUVORK5CYII%3D';
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
if (window.location.host.match(/orpheus\.network|redacted\.ch|passtheheadphones\.me|lztr\.(us|me)|mutracker\.org|notwhat\.cd/)) {
|
||||
LOGGER.info('Gazelle site detected');
|
||||
gazellePageHandler();
|
||||
|
@ -50,14 +50,14 @@ function avaxHomePageHandler() {
|
|||
|
||||
// Find and analyze EAC log
|
||||
$('div.spoiler')
|
||||
.filter(function() {
|
||||
.filter(function () {
|
||||
return $(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.match(/(EAC|log)/i);
|
||||
})
|
||||
.find('div')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let $eacLog = $(this);
|
||||
let discs = analyze_log_files($eacLog);
|
||||
|
||||
|
@ -66,7 +66,7 @@ function avaxHomePageHandler() {
|
|||
artistName,
|
||||
releaseName,
|
||||
discs,
|
||||
function(mb_toc_numbers, discid, discNumber) {
|
||||
function (mb_toc_numbers, discid, discNumber) {
|
||||
$eacLog
|
||||
.parents('div.spoiler')
|
||||
.prevAll('div.center:first')
|
||||
|
@ -74,7 +74,7 @@ function avaxHomePageHandler() {
|
|||
`<br /><strong>${discs.length > 1 ? `Disc ${discNumber}: ` : ''}MB DiscId </strong><span id="${discid}" />`
|
||||
);
|
||||
},
|
||||
function(mb_toc_numbers, discid, discNumber, found) {
|
||||
function (mb_toc_numbers, discid, discNumber, found) {
|
||||
let url = computeAttachURL(mb_toc_numbers, artistName, releaseName);
|
||||
let html = `<a href="${url}">${discid}</a>`;
|
||||
if (found) {
|
||||
|
@ -101,21 +101,21 @@ function gazellePageHandler() {
|
|||
|
||||
// Parse each torrent
|
||||
$('tr.group_torrent')
|
||||
.filter(function() {
|
||||
.filter(function () {
|
||||
return $(this).attr('id');
|
||||
})
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let torrentInfo = $(this).next();
|
||||
|
||||
$(torrentInfo)
|
||||
.find('a')
|
||||
// Only investigate the ones with a log
|
||||
.filter(function(index) {
|
||||
.filter(function (index) {
|
||||
return $(this)
|
||||
.text()
|
||||
.match(/View\s+Log/i);
|
||||
})
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
LOGGER.debug('Log link', this);
|
||||
if (
|
||||
$(this)
|
||||
|
@ -157,7 +157,7 @@ function gazellePageHandler() {
|
|||
LOGGER.debug('targetContainer: ', targetContainer);
|
||||
|
||||
// Get log content
|
||||
$.get(logUrl, function(data) {
|
||||
$.get(logUrl, function (data) {
|
||||
LOGGER.debug('Log content', $(data).find('pre'));
|
||||
let discs = analyze_log_files($(data).find('pre'));
|
||||
LOGGER.debug('Number of disc found', discs.length);
|
||||
|
@ -165,14 +165,14 @@ function gazellePageHandler() {
|
|||
artistName,
|
||||
releaseName,
|
||||
discs,
|
||||
function(mb_toc_numbers, discid, discNumber) {
|
||||
function (mb_toc_numbers, discid, discNumber) {
|
||||
targetContainer.append(
|
||||
`<br /><strong>${
|
||||
discs.length > 1 ? `Disc ${discNumber}: ` : ''
|
||||
}MB DiscId: </strong><span id="${torrentId}_disc${discNumber}" />`
|
||||
);
|
||||
},
|
||||
function(mb_toc_numbers, discid, discNumber, found) {
|
||||
function (mb_toc_numbers, discid, discNumber, found) {
|
||||
let url = computeAttachURL(mb_toc_numbers, artistName, releaseName);
|
||||
let html = `<a href="${url}">${discid}</a>`;
|
||||
if (found) {
|
||||
|
@ -198,7 +198,7 @@ function computeAttachURL(mb_toc_numbers, artistName, releaseName) {
|
|||
|
||||
function analyze_log_files(log_files) {
|
||||
let discs = [];
|
||||
$.each(log_files, function(i, log_file) {
|
||||
$.each(log_files, function (i, log_file) {
|
||||
let discsInLog = MBDiscid.log_input_to_entries($(log_file).text());
|
||||
for (var i = 0; i < discsInLog.length; i++) {
|
||||
discs.push(discsInLog[i]);
|
||||
|
@ -233,13 +233,13 @@ function check_and_display_discs(artistName, releaseName, discs, displayDiscHand
|
|||
displayDiscHandler(mb_toc_numbers, discid, discNumber);
|
||||
|
||||
// Now check if this discid is known by MusicBrainz
|
||||
(function(discid, discNumber, mb_toc_numbers) {
|
||||
(function (discid, discNumber, mb_toc_numbers) {
|
||||
let query = $.getJSON(`//musicbrainz.org/ws/2/discid/${discid}?cdstubs=no`);
|
||||
query.done(function(data) {
|
||||
query.done(function (data) {
|
||||
let existsInMusicbrainz = !('error' in data) && data.error != 'Not found';
|
||||
displayResultHandler(mb_toc_numbers, discid, discNumber, existsInMusicbrainz);
|
||||
});
|
||||
query.fail(function() {
|
||||
query.fail(function () {
|
||||
// If discid is not found, the webservice returns a 404 http code
|
||||
displayResultHandler(mb_toc_numbers, discid, discNumber, false);
|
||||
});
|
||||
|
@ -254,7 +254,7 @@ function check_and_display_discs(artistName, releaseName, discs, displayDiscHand
|
|||
// Copyright 2010, kolen
|
||||
// Released under the MIT License
|
||||
|
||||
var MBDiscid = (function() {
|
||||
var MBDiscid = (function () {
|
||||
this.SECTORS_PER_SECOND = 75;
|
||||
this.PREGAP = 150;
|
||||
this.DATA_TRACK_GAP = 11400;
|
||||
|
@ -272,10 +272,10 @@ var MBDiscid = (function() {
|
|||
'(\\d+)' + // 5 - end sector
|
||||
'\\s*$'
|
||||
);
|
||||
this.log_input_to_entries = function(text) {
|
||||
this.log_input_to_entries = function (text) {
|
||||
let discs = [];
|
||||
var entries = [];
|
||||
$.each(text.split('\n'), function(index, value) {
|
||||
$.each(text.split('\n'), function (index, value) {
|
||||
let m = toc_entry_matcher.exec(value);
|
||||
if (m) {
|
||||
// New disc
|
||||
|
@ -306,7 +306,7 @@ var MBDiscid = (function() {
|
|||
return discs;
|
||||
};
|
||||
|
||||
this.get_layout_type = function(entries) {
|
||||
this.get_layout_type = function (entries) {
|
||||
let type = 'standard';
|
||||
for (let i = 0; i < entries.length - 1; i++) {
|
||||
let gap = parseInt(entries[i + 1][4], 10) - parseInt(entries[i][5], 10) - 1;
|
||||
|
@ -322,21 +322,21 @@ var MBDiscid = (function() {
|
|||
return type;
|
||||
};
|
||||
|
||||
this.calculate_mb_toc_numbers = function(entries) {
|
||||
this.calculate_mb_toc_numbers = function (entries) {
|
||||
if (entries.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let leadout_offset = parseInt(entries[entries.length - 1][5], 10) + PREGAP + 1;
|
||||
|
||||
let offsets = $.map(entries, function(entry) {
|
||||
let offsets = $.map(entries, function (entry) {
|
||||
return parseInt(entry[4], 10) + PREGAP;
|
||||
});
|
||||
return [1, entries.length, leadout_offset].concat(offsets);
|
||||
};
|
||||
|
||||
this.calculate_cddb_id = function(entries) {
|
||||
let sum_of_digits = function(n) {
|
||||
this.calculate_cddb_id = function (entries) {
|
||||
let sum_of_digits = function (n) {
|
||||
let sum = 0;
|
||||
while (n > 0) {
|
||||
sum = sum + (n % 10);
|
||||
|
@ -345,7 +345,7 @@ var MBDiscid = (function() {
|
|||
return sum;
|
||||
};
|
||||
|
||||
let decimalToHexString = function(number) {
|
||||
let decimalToHexString = function (number) {
|
||||
if (number < 0) {
|
||||
number = 0xffffffff + number + 1;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ var MBDiscid = (function() {
|
|||
(parseInt(entries[entries.length - 1][5], 10) - parseInt(entries[0][4], 10) + 1) / SECTORS_PER_SECOND
|
||||
);
|
||||
let checksum = 0;
|
||||
$.each(entries, function(index, entry) {
|
||||
$.each(entries, function (index, entry) {
|
||||
checksum += sum_of_digits(Math.floor((parseInt(entry[4], 10) + PREGAP) / SECTORS_PER_SECOND));
|
||||
});
|
||||
|
||||
|
@ -367,11 +367,9 @@ var MBDiscid = (function() {
|
|||
return decimalToHexString(discid_num);
|
||||
};
|
||||
|
||||
this.calculate_mb_discid = function(entries) {
|
||||
let hex_left_pad = function(input, totalChars) {
|
||||
input = `${parseInt(input, 10)
|
||||
.toString(16)
|
||||
.toUpperCase()}`;
|
||||
this.calculate_mb_discid = function (entries) {
|
||||
let hex_left_pad = function (input, totalChars) {
|
||||
input = `${parseInt(input, 10).toString(16).toUpperCase()}`;
|
||||
let padWith = '0';
|
||||
if (input.length < totalChars) {
|
||||
while (input.length < totalChars) {
|
||||
|
@ -401,10 +399,7 @@ var MBDiscid = (function() {
|
|||
|
||||
b64pad = '=';
|
||||
let discid = b64_sha1(message);
|
||||
discid = discid
|
||||
.replace(/\+/g, '.')
|
||||
.replace(/\//g, '_')
|
||||
.replace(/=/g, '-');
|
||||
discid = discid.replace(/\+/g, '.').replace(/\//g, '_').replace(/=/g, '-');
|
||||
return discid;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,29 +23,29 @@ var relationsIconsURLs = {
|
|||
'cover art link': 'http://www.cdcovers.cc/favicon.ico',
|
||||
secondhandsongs: 'https://musicbrainz.org/static/images/favicons/secondhandsongs-32.png',
|
||||
lyrics: 'http://www.nomy.nu/img/lyrics-icon.gif',
|
||||
allmusic: 'https://musicbrainz.org/static/images/favicons/allmusic-16.png'
|
||||
allmusic: 'https://musicbrainz.org/static/images/favicons/allmusic-16.png',
|
||||
},
|
||||
'release-group': {
|
||||
'single from': 'http://www.amaesingtools.com/images/left_arrow_icon.gif'
|
||||
'single from': 'http://www.amaesingtools.com/images/left_arrow_icon.gif',
|
||||
},
|
||||
release: {
|
||||
'part of set': 'http://web.archive.org/web/20060709091901/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-inter.png',
|
||||
remaster: 'http://web.archive.org/web/20060708200714/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-www.png'
|
||||
}
|
||||
remaster: 'http://web.archive.org/web/20060708200714/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-www.png',
|
||||
},
|
||||
};
|
||||
|
||||
var otherDatabasesIconURLs = {
|
||||
'd-nb.info': 'https://musicbrainz.org/static/images/favicons/dnb-16.png',
|
||||
'www.musik-sammler.de': 'https://musicbrainz.org/static/images/favicons/musiksammler-32.png',
|
||||
'www.worldcat.org': 'https://musicbrainz.org/static/images/favicons/worldcat-32.png',
|
||||
'rateyourmusic.com': 'https://musicbrainz.org/static/images/favicons/rateyourmusic-32.png'
|
||||
'rateyourmusic.com': 'https://musicbrainz.org/static/images/favicons/rateyourmusic-32.png',
|
||||
};
|
||||
|
||||
var incOptions = {
|
||||
'release-group': ['release-group-rels', 'url-rels'],
|
||||
release: ['release-rels', 'url-rels', 'discids'],
|
||||
recording: ['work-rels'],
|
||||
work: ['url-rels']
|
||||
work: ['url-rels'],
|
||||
};
|
||||
|
||||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
|
@ -53,7 +53,7 @@ this.$ = this.jQuery = jQuery.noConflict(true);
|
|||
|
||||
if (!unsafeWindow) unsafeWindow = window;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Get pageType (label or artist)
|
||||
let parent = {};
|
||||
let child = {};
|
||||
|
@ -78,19 +78,11 @@ $(document).ready(function() {
|
|||
|
||||
// Determine target column
|
||||
let columnindex = 0;
|
||||
$("table.tbl tbody tr[class!='subh']").each(function() {
|
||||
$("table.tbl tbody tr[class!='subh']").each(function () {
|
||||
$(this)
|
||||
.children('td')
|
||||
.each(function() {
|
||||
if (
|
||||
$(this)
|
||||
.find('a')
|
||||
.attr('href') !== undefined &&
|
||||
$(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.match(mbidRE)
|
||||
) {
|
||||
.each(function () {
|
||||
if ($(this).find('a').attr('href') !== undefined && $(this).find('a').attr('href').match(mbidRE)) {
|
||||
return false;
|
||||
}
|
||||
columnindex++;
|
||||
|
@ -99,7 +91,7 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
// Set MBID to row in tables to get easiest fastest access
|
||||
$("table.tbl tr[class!='subh']").each(function() {
|
||||
$("table.tbl tr[class!='subh']").each(function () {
|
||||
let $tr = $(this);
|
||||
|
||||
$tr.children(`th:eq(${columnindex})`).after("<th style='width: 150px;'>Relationships</th>");
|
||||
|
@ -107,7 +99,7 @@ $(document).ready(function() {
|
|||
|
||||
$(this)
|
||||
.find('a')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let href = $(this).attr('href');
|
||||
if ((m = href.match(mbidRE))) {
|
||||
$tr.attr('id', m[2]);
|
||||
|
@ -127,21 +119,19 @@ $(document).ready(function() {
|
|||
let url = `/ws/2/${child.type}?${parent.type}=${parent.mbid}&inc=${incOptions[child.type].join('+')}&limit=100&offset=${offset}`;
|
||||
//console.log("MB WS url: " + url);
|
||||
|
||||
$.get(url, function(data, textStatus, jqXHR) {
|
||||
$.get(url, function (data, textStatus, jqXHR) {
|
||||
// Parse each child
|
||||
$(data)
|
||||
.find(child.type)
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let mbid = $(this).attr('id');
|
||||
|
||||
// URL relationships
|
||||
$(this)
|
||||
.find("relation-list[target-type='url'] relation")
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let reltype = $(this).attr('type');
|
||||
let target = $(this)
|
||||
.children('target')
|
||||
.text();
|
||||
let target = $(this).children('target').text();
|
||||
if (Object.prototype.hasOwnProperty.call(relationsIconsURLs.url, reltype)) {
|
||||
$(`#${mbid} td.relationships`).append(
|
||||
`<a href='${target.replace(/'/g, ''')}'>` +
|
||||
|
@ -163,10 +153,8 @@ $(document).ready(function() {
|
|||
// Other relationships
|
||||
$(this)
|
||||
.find("relation-list[target-type!='url']")
|
||||
.each(function() {
|
||||
let targettype = $(this)
|
||||
.attr('target-type')
|
||||
.replace('release_group', 'release-group');
|
||||
.each(function () {
|
||||
let targettype = $(this).attr('target-type').replace('release_group', 'release-group');
|
||||
let relations = {};
|
||||
|
||||
if (relationsIconsURLs[targettype] === undefined) {
|
||||
|
@ -175,11 +163,9 @@ $(document).ready(function() {
|
|||
|
||||
$(this)
|
||||
.children('relation')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let reltype = $(this).attr('type');
|
||||
let target = $(this)
|
||||
.children('target')
|
||||
.text();
|
||||
let target = $(this).children('target').text();
|
||||
let url = targettype == 'url' ? target : `/${targettype}/${target}`;
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(relationsIconsURLs[targettype], reltype)) {
|
||||
|
@ -188,12 +174,12 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$.each(relations, function(reltype, urls) {
|
||||
$.each(relations, function (reltype, urls) {
|
||||
let html = '';
|
||||
if (urls.length < -1) {
|
||||
html += `<img src='${relationsIconsURLs[targettype][reltype]}' />(${urls.length}) `;
|
||||
} else {
|
||||
$.each(urls, function(index, url) {
|
||||
$.each(urls, function (index, url) {
|
||||
html += `<a href='${url}'><img src='${relationsIconsURLs[targettype][reltype]}' /></a> `;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,23 +14,23 @@
|
|||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
LASTFM_APIKEY = null;
|
||||
|
||||
// Highlight table rows
|
||||
$('table.tbl tbody tr').hover(
|
||||
function() {
|
||||
function () {
|
||||
$(this)
|
||||
.children('td')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let backgroundColor = $(this).css('backgroundColor');
|
||||
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '#ffeea8');
|
||||
});
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
$(this)
|
||||
.children('td')
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
let backgroundColor = $(this).css('backgroundColor');
|
||||
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '');
|
||||
});
|
||||
|
@ -46,8 +46,8 @@ $(document).ready(function() {
|
|||
var mbid = window.location.href.match(re)[1];
|
||||
let toptracks = $.getJSON(
|
||||
`http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&mbid=${mbid}&api_key=${LASTFM_APIKEY}&format=json`,
|
||||
function(data) {
|
||||
$.each(data.toptracks.track, function(index, track) {
|
||||
function (data) {
|
||||
$.each(data.toptracks.track, function (index, track) {
|
||||
if (index >= 5) return true;
|
||||
let url = track.mbid ? `/recording/${track.mbid}` : track.url;
|
||||
$('ul.toptracks').append(`<li><a href="${url}">${track.name}</a></li>`);
|
||||
|
@ -78,7 +78,7 @@ $(document).ready(function() {
|
|||
$("#sidebar h2:contains('Rating')").before(
|
||||
$("#sidebar h2:contains('External links')")
|
||||
.nextAll('ul.external_links')
|
||||
.filter(function() {
|
||||
.filter(function () {
|
||||
return !pageHasRGLinks || $(this).nextAll("h2:contains('Release group external links')").length > 0;
|
||||
})
|
||||
);
|
||||
|
@ -102,10 +102,8 @@ $(document).ready(function() {
|
|||
);
|
||||
if (window.location.href.match(re)) {
|
||||
$('form')
|
||||
.filter(function() {
|
||||
return $(this)
|
||||
.prop('action')
|
||||
.match('merge_queue');
|
||||
.filter(function () {
|
||||
return $(this).prop('action').match('merge_queue');
|
||||
})
|
||||
.attr('target', '_blank');
|
||||
}
|
||||
|
@ -113,14 +111,9 @@ $(document).ready(function() {
|
|||
// Modify link to edits: remove " - <Edit type>" from the link "Edit XXXX - <Edit type>"
|
||||
re = new RegExp('musicbrainz.org/.*/(open_)?edits', 'i');
|
||||
if (window.location.href.match(re)) {
|
||||
$('div.edit-description ~ h2').each(function() {
|
||||
let parts = $(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.split(' - ');
|
||||
$(this)
|
||||
.find('a')
|
||||
.text(parts[0]);
|
||||
$('div.edit-description ~ h2').each(function () {
|
||||
let parts = $(this).find('a').text().split(' - ');
|
||||
$(this).find('a').text(parts[0]);
|
||||
$(this).append(` - ${parts[1]}`);
|
||||
});
|
||||
}
|
||||
|
@ -128,10 +121,8 @@ $(document).ready(function() {
|
|||
// Add direct link to cover art tab for Add cover art edits
|
||||
re = new RegExp('musicbrainz.org/(.*/(open_)?edits|edit/d+)', 'i');
|
||||
if (window.location.href.match(re)) {
|
||||
$("div.edit-description ~ h2:contains('cover art')").each(function() {
|
||||
$editdetails = $(this)
|
||||
.parents('.edit-header')
|
||||
.siblings('.edit-details');
|
||||
$("div.edit-description ~ h2:contains('cover art')").each(function () {
|
||||
$editdetails = $(this).parents('.edit-header').siblings('.edit-details');
|
||||
mbid = $editdetails
|
||||
.find("a[href*='musicbrainz.org/release/']")
|
||||
.attr('href')
|
||||
|
@ -168,21 +159,18 @@ $(document).ready(function() {
|
|||
re = new RegExp('musicbrainz.org/artist/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/recordings', 'i');
|
||||
if (window.location.href.match(re)) {
|
||||
let isrcColNo; // = ($("#content table.tbl thead th:eq(2)").text() == "Artist") ? 3 : 2;
|
||||
$('#content table.tbl thead th').each(function(index, th) {
|
||||
$('#content table.tbl thead th').each(function (index, th) {
|
||||
if ($(th).text() == 'ISRCs') {
|
||||
isrcColNo = index;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
let reg = new RegExp('([A-Z]{2}[A-Z0-9]{3}[0-9]{7})');
|
||||
$('#content table.tbl tbody tr').each(function() {
|
||||
$('#content table.tbl tbody tr').each(function () {
|
||||
let $td = $(this).find(`td:eq(${isrcColNo})`);
|
||||
let isrcs = $td
|
||||
.text()
|
||||
.trim()
|
||||
.split('\n<br>\n');
|
||||
let isrcs = $td.text().trim().split('\n<br>\n');
|
||||
let newHTML = '';
|
||||
$.each(isrcs, function(index, isrc) {
|
||||
$.each(isrcs, function (index, isrc) {
|
||||
isrc = isrc.trim();
|
||||
newHTML += `<a href='/isrc/${isrc}'><code>`;
|
||||
newHTML += `${isrc.substring(0, 5)}<b>${isrc.substring(5, 7)}</b>${isrc.substring(7)}`;
|
||||
|
@ -202,25 +190,25 @@ $(document).ready(function() {
|
|||
var mbid = window.location.href.match(re)[1];
|
||||
// Get tracks data from webservice
|
||||
let wsurl = `/ws/2/release/${mbid}?inc=isrcs+recordings`;
|
||||
$.getJSON(wsurl, function(data) {
|
||||
$.getJSON(wsurl, function (data) {
|
||||
// Store tracks data from webservice in a hash table
|
||||
let tracks = {};
|
||||
$.each(data.media, function(index, medium) {
|
||||
$.each(medium.tracks, function(i, track) {
|
||||
$.each(data.media, function (index, medium) {
|
||||
$.each(medium.tracks, function (i, track) {
|
||||
tracks[track.id] = track;
|
||||
});
|
||||
});
|
||||
// Different behavior depending on the number of mediums
|
||||
if ($('table.medium').length <= 10) {
|
||||
// All mediums are already displayed: handle them now
|
||||
$('table.medium').each(function() {
|
||||
$('table.medium').each(function () {
|
||||
handleMedium($(this), tracks);
|
||||
});
|
||||
} else {
|
||||
// Each medium will be handled when it's loaded
|
||||
let HANDLED_ATTRIBUTE = 'ui_enh_isrcs_handled';
|
||||
$('table.medium').attr(HANDLED_ATTRIBUTE, 'no');
|
||||
$('table.medium').bind('DOMNodeInserted', function(event) {
|
||||
$('table.medium').bind('DOMNodeInserted', function (event) {
|
||||
$target = $(event.target);
|
||||
if (
|
||||
$target.prop('nodeName') == 'TBODY' &&
|
||||
|
@ -238,17 +226,10 @@ $(document).ready(function() {
|
|||
|
||||
function handleMedium($medium, ws_tracks) {
|
||||
// Extend colspan for medium table header
|
||||
$medium.find('thead tr').each(function() {
|
||||
$medium.find('thead tr').each(function () {
|
||||
$(this)
|
||||
.find('th:eq(0)')
|
||||
.attr(
|
||||
'colspan',
|
||||
$(this)
|
||||
.find('th:eq(0)')
|
||||
.attr('colspan') *
|
||||
1 +
|
||||
1
|
||||
);
|
||||
.attr('colspan', $(this).find('th:eq(0)').attr('colspan') * 1 + 1);
|
||||
});
|
||||
// Table sub-header
|
||||
$medium
|
||||
|
@ -256,7 +237,7 @@ $(document).ready(function() {
|
|||
.before("<th style='width: 150px;' class='isrc c'> ISRC </th>");
|
||||
|
||||
// Handle each track
|
||||
$medium.find('tbody tr[id]').each(function(index, medium_track) {
|
||||
$medium.find('tbody tr[id]').each(function (index, medium_track) {
|
||||
track_mbid = $(medium_track).attr('id');
|
||||
let isrcsLinks = '';
|
||||
if (Object.prototype.hasOwnProperty.call(ws_tracks, track_mbid)) {
|
||||
|
@ -264,18 +245,14 @@ $(document).ready(function() {
|
|||
let recording = track.recording;
|
||||
// Recording comment
|
||||
if (recording.disambiguation != '') {
|
||||
let td_title_index = $(`#${track_mbid}`)
|
||||
.find('td:eq(1)')
|
||||
.hasClass('video')
|
||||
? 2
|
||||
: 1;
|
||||
let td_title_index = $(`#${track_mbid}`).find('td:eq(1)').hasClass('video') ? 2 : 1;
|
||||
$(`#${track_mbid}`)
|
||||
.find(`td:eq(${td_title_index}) a:eq(0)`)
|
||||
.after(` <span class="comment">(${recording.disambiguation})</span>`);
|
||||
}
|
||||
// ISRCS
|
||||
if (recording.isrcs.length != 0) {
|
||||
let links = jQuery.map(recording.isrcs, function(isrc, i) {
|
||||
let links = jQuery.map(recording.isrcs, function (isrc, i) {
|
||||
return `<a href='/isrc/${isrc}'>${isrc}</a>`;
|
||||
});
|
||||
isrcsLinks = links.join(', ');
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
||||
this.$ = this.jQuery = jQuery.noConflict(true);
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
|
||||
let release_url = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
|
||||
|
@ -45,13 +45,13 @@ function setreleasedate(release, datestring) {
|
|||
function getGenericalData() {
|
||||
let rdata = new Array();
|
||||
let keydata = $('dl.float_left dt, dl.float_right dt')
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
let s = $.trim($(this).text());
|
||||
return s.substring(0, s.length - 1);
|
||||
})
|
||||
.get();
|
||||
let valuedata = $('dl.float_left dd,dl.float_right dd')
|
||||
.map(function() {
|
||||
.map(function () {
|
||||
return $.trim($(this).text());
|
||||
})
|
||||
.get();
|
||||
|
@ -62,12 +62,7 @@ function getGenericalData() {
|
|||
}
|
||||
|
||||
function getArtistsList() {
|
||||
return $.map(
|
||||
$('h2.band_name')
|
||||
.text()
|
||||
.split('/'),
|
||||
$.trim
|
||||
);
|
||||
return $.map($('h2.band_name').text().split('/'), $.trim);
|
||||
}
|
||||
|
||||
function retrieveReleaseInfo(release_url) {
|
||||
|
@ -87,7 +82,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
packaging: '',
|
||||
language: '',
|
||||
script: '',
|
||||
urls: []
|
||||
urls: [],
|
||||
};
|
||||
|
||||
let rdata = getGenericalData();
|
||||
|
@ -104,7 +99,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
release.artist_credit.push({
|
||||
artist_name: artists[i],
|
||||
credited_name: artists[i],
|
||||
joinphrase: i != artists.length - 1 ? joinphrase : ''
|
||||
joinphrase: i != artists.length - 1 ? joinphrase : '',
|
||||
});
|
||||
}
|
||||
release.title = $('h1.album_name').text();
|
||||
|
@ -125,7 +120,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
release.labels.push({
|
||||
name: label,
|
||||
catno: catno,
|
||||
mbid: label_mbid
|
||||
mbid: label_mbid,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -150,9 +145,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
}
|
||||
}
|
||||
|
||||
let identifiers = $('#album_tabs_notes > div:nth-child(2)')
|
||||
.find('p:not([class])')
|
||||
.contents();
|
||||
let identifiers = $('#album_tabs_notes > div:nth-child(2)').find('p:not([class])').contents();
|
||||
for (let j = 0; j < identifiers.length; j++) {
|
||||
if (identifiers[j].textContent.indexOf('Barcode:') != -1) {
|
||||
release.barcode = $.trim(identifiers[j].textContent.substring(8));
|
||||
|
@ -164,25 +157,25 @@ function retrieveReleaseInfo(release_url) {
|
|||
let link_type = MBImport.URL_TYPES;
|
||||
release.urls.push({
|
||||
url: release_url,
|
||||
link_type: link_type.other_databases
|
||||
link_type: link_type.other_databases,
|
||||
});
|
||||
|
||||
let releaseNumber = 0;
|
||||
let disc = {
|
||||
tracks: [],
|
||||
format: release.format
|
||||
format: release.format,
|
||||
};
|
||||
release.discs.push(disc);
|
||||
|
||||
let tracksline = $('table.table_lyrics tr.even,table.table_lyrics tr.odd');
|
||||
|
||||
tracksline.each(function(index, element) {
|
||||
tracksline.each(function (index, element) {
|
||||
let trackNumber = $.trim(element.children[0].textContent).replace('.', '');
|
||||
if (trackNumber == '1' && trackNumber != index + 1) {
|
||||
releaseNumber++;
|
||||
release.discs.push({
|
||||
tracks: [],
|
||||
format: release.format
|
||||
format: release.format,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -191,7 +184,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
number: trackNumber,
|
||||
title: $.trim(element.children[1].textContent.replace(/\s+/g, ' ')),
|
||||
duration: $.trim(element.children[2].textContent),
|
||||
artist_credit: [release.artist_credit]
|
||||
artist_credit: [release.artist_credit],
|
||||
};
|
||||
release.discs[releaseNumber].tracks.push(track);
|
||||
});
|
||||
|
@ -207,14 +200,14 @@ function insertLink(release, release_url) {
|
|||
|
||||
$('h2.band_name').after(mbUI);
|
||||
$('#musicbrainz-import form').css({
|
||||
padding: '0'
|
||||
padding: '0',
|
||||
});
|
||||
$('form.musicbrainz_import').css({
|
||||
display: 'inline-block',
|
||||
margin: '1px'
|
||||
margin: '1px',
|
||||
});
|
||||
$('form.musicbrainz_import img').css({
|
||||
display: 'inline-block'
|
||||
display: 'inline-block',
|
||||
});
|
||||
|
||||
mbUI.slideDown();
|
||||
|
@ -249,7 +242,7 @@ var ReleaseTypes = {
|
|||
EP: ['ep'],
|
||||
Compilation: ['album', 'compilation'],
|
||||
Split: ['album'],
|
||||
Collaboration: ['']
|
||||
Collaboration: [''],
|
||||
};
|
||||
|
||||
//ReleaseFormat[MAformat]="MBformat";
|
||||
|
@ -265,5 +258,5 @@ var ReleaseFormat = {
|
|||
'2 12" vinyls': '12" Vinyl',
|
||||
'12" vinyl (33⅓ RPM)': '12" Vinyl',
|
||||
Cassette: 'Cassette',
|
||||
Digital: 'Digital Media'
|
||||
Digital: 'Digital Media',
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ function getPerformers(trackobj) {
|
|||
trackobj.performers
|
||||
.replace('\r', '')
|
||||
.split(' - ')
|
||||
.map(function(v) {
|
||||
.map(function (v) {
|
||||
let list = v.split(', ');
|
||||
let name = list.shift();
|
||||
return [name, list];
|
||||
|
@ -99,7 +99,7 @@ function parseRelease(data) {
|
|||
release.urls = [];
|
||||
release.urls.push({
|
||||
url: release.url,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download
|
||||
link_type: MBImport.URL_TYPES.purchase_for_download,
|
||||
});
|
||||
|
||||
// release timestamps are using France time + daylight saving (GMT+1 or GMT+2),
|
||||
|
@ -110,10 +110,10 @@ function parseRelease(data) {
|
|||
release.day = releaseDate.getUTCDate();
|
||||
|
||||
release.labels = [];
|
||||
$.each(data.label.name.split(' - '), function(index, label) {
|
||||
$.each(data.label.name.split(' - '), function (index, label) {
|
||||
release.labels.push({
|
||||
name: label,
|
||||
catno: '[none]' // no catno on qobuz ?
|
||||
catno: '[none]', // no catno on qobuz ?
|
||||
});
|
||||
});
|
||||
release.isrcs = [];
|
||||
|
@ -122,17 +122,17 @@ function parseRelease(data) {
|
|||
let tracks = [],
|
||||
classical_tracks = [],
|
||||
old_media_num = 1;
|
||||
$.each(data.tracks.items, function(index, trackobj) {
|
||||
$.each(data.tracks.items, function (index, trackobj) {
|
||||
release.isrcs.push(trackobj.isrc);
|
||||
if (trackobj.media_number != old_media_num) {
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: 'Digital Media'
|
||||
format: 'Digital Media',
|
||||
});
|
||||
if (is_classical) {
|
||||
release.classical.discs.push({
|
||||
tracks: classical_tracks,
|
||||
format: 'Digital Media'
|
||||
format: 'Digital Media',
|
||||
});
|
||||
classical_tracks = [];
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ function parseRelease(data) {
|
|||
if (typeof trackobj.composer !== 'undefined') {
|
||||
classical_artists.push(trackobj.composer.name);
|
||||
} else {
|
||||
$.each(performers, function(index, performer) {
|
||||
$.each(performers, function (index, performer) {
|
||||
if ($.inArray('Composer', performer[1]) != -1) {
|
||||
classical_artists.push(performer[0]);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ function parseRelease(data) {
|
|||
|
||||
let artists = [];
|
||||
let featured_artists = [];
|
||||
$.each(performers, function(index, performer) {
|
||||
$.each(performers, function (index, performer) {
|
||||
if ($.inArray('Featured Artist', performer[1]) != -1) {
|
||||
featured_artists.push(performer[0]);
|
||||
} else if (
|
||||
|
@ -187,12 +187,12 @@ function parseRelease(data) {
|
|||
});
|
||||
release.discs.push({
|
||||
tracks: tracks,
|
||||
format: 'Digital Media'
|
||||
format: 'Digital Media',
|
||||
});
|
||||
if (is_classical) {
|
||||
release.classical.discs.push({
|
||||
tracks: classical_tracks,
|
||||
format: 'Digital Media'
|
||||
format: 'Digital Media',
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -232,9 +232,7 @@ function insertLink(release) {
|
|||
parameters = MBImport.buildFormParameters(release, edit_note),
|
||||
$album_form = $(MBImport.buildFormHTML(parameters)),
|
||||
search_form = MBImport.buildSearchButton(release);
|
||||
let mbUI = $('<p class="musicbrainz_import">')
|
||||
.append($album_form, search_form)
|
||||
.hide();
|
||||
let mbUI = $('<p class="musicbrainz_import">').append($album_form, search_form).hide();
|
||||
|
||||
if (is_classical) {
|
||||
let classical_release = $.extend({}, release);
|
||||
|
@ -271,12 +269,12 @@ function insertLink(release) {
|
|||
$('#info div.meta').append(mbUI);
|
||||
$('form.musicbrainz_import').css({
|
||||
display: 'inline-block',
|
||||
margin: '1px'
|
||||
margin: '1px',
|
||||
});
|
||||
$('form.musicbrainz_import img').css({
|
||||
display: 'inline-block',
|
||||
width: '16px',
|
||||
height: '16px'
|
||||
height: '16px',
|
||||
});
|
||||
$('label.musicbrainz_import').css({
|
||||
'white-space': 'nowrap',
|
||||
|
@ -292,19 +290,19 @@ function insertLink(release) {
|
|||
'background-color': 'rgba(240,240,240,0.8)',
|
||||
color: '#334',
|
||||
height: '26px',
|
||||
'box-sizing': 'border-box'
|
||||
'box-sizing': 'border-box',
|
||||
});
|
||||
$('label.musicbrainz_import input').css({
|
||||
margin: '0 4px 0 0'
|
||||
margin: '0 4px 0 0',
|
||||
});
|
||||
mbUI.slideDown();
|
||||
}
|
||||
|
||||
// Hook all XMLHttpRequest to use the data fetched by the official web-player.
|
||||
(function() {
|
||||
(function () {
|
||||
const send = XMLHttpRequest.prototype.send;
|
||||
XMLHttpRequest.prototype.send = function() {
|
||||
this.addEventListener('load', function() {
|
||||
XMLHttpRequest.prototype.send = function () {
|
||||
this.addEventListener('load', function () {
|
||||
let wsUrl = 'https://www.qobuz.com/api.json/0.2/album/get?album_id=';
|
||||
let repUrl = arguments[0].currentTarget.responseURL;
|
||||
if (repUrl.startsWith(wsUrl)) {
|
||||
|
@ -322,18 +320,16 @@ function insertLink(release) {
|
|||
};
|
||||
})();
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
MBImportStyle();
|
||||
|
||||
// replace image zoom link by the maximum size image link
|
||||
let maximgurl = $('#product-cover-link')
|
||||
.attr('href')
|
||||
.replace('_600', '_max');
|
||||
let maximgurl = $('#product-cover-link').attr('href').replace('_600', '_max');
|
||||
let maximg = new Image();
|
||||
maximg.onerror = function(evt) {
|
||||
maximg.onerror = function (evt) {
|
||||
LOGGER.debug('No max image');
|
||||
};
|
||||
maximg.onload = function(evt) {
|
||||
maximg.onload = function (evt) {
|
||||
$('#product-cover-link').attr('href', maximgurl);
|
||||
$('#product-cover-link').attr(
|
||||
'title',
|
||||
|
@ -343,7 +339,7 @@ $(document).ready(function() {
|
|||
maximg.src = maximgurl;
|
||||
});
|
||||
|
||||
$(document).on('click', '#isrcs', function() {
|
||||
$(document).on('click', '#isrcs', function () {
|
||||
$('#isrclist').toggle();
|
||||
if ($('#isrclist').is(':visible')) {
|
||||
$('#isrclist').select();
|
||||
|
@ -352,6 +348,6 @@ $(document).on('click', '#isrcs', function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '#force_album_artist', function() {
|
||||
$(document).on('click', '#force_album_artist', function () {
|
||||
changeAlbumArtist();
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ function setRecordingComments() {
|
|||
)
|
||||
);
|
||||
|
||||
var delay = setInterval(function() {
|
||||
var delay = setInterval(function () {
|
||||
$tracks = $('.medium tbody tr[id]');
|
||||
|
||||
if ($tracks.length) {
|
||||
|
@ -65,14 +65,10 @@ function setRecordingComments() {
|
|||
return;
|
||||
}
|
||||
|
||||
$tracks.each(function() {
|
||||
let $td = $(this)
|
||||
.children('td:not(.pos):not(.video):not(.rating):not(.treleases)')
|
||||
.has('a[href^=\\/recording\\/]'),
|
||||
$tracks.each(function () {
|
||||
let $td = $(this).children('td:not(.pos):not(.video):not(.rating):not(.treleases)').has('a[href^=\\/recording\\/]'),
|
||||
node = $td.children('td > .mp, td > .name-variation, td > a[href^=\\/recording\\/]').filter(':first'),
|
||||
$input = $('<input />')
|
||||
.addClass('recording-comment')
|
||||
.insertAfter(node);
|
||||
$input = $('<input />').addClass('recording-comment').insertAfter(node);
|
||||
|
||||
if (!editing) {
|
||||
$input.hide();
|
||||
|
@ -83,15 +79,12 @@ function setRecordingComments() {
|
|||
|
||||
let release = location.pathname.match(MBID_REGEX)[0];
|
||||
|
||||
$.get(`/ws/2/release/${release}?inc=recordings&fmt=json`, function(data) {
|
||||
$.get(`/ws/2/release/${release}?inc=recordings&fmt=json`, function (data) {
|
||||
let comments = _.map(_.map(_.flatten(_.map(data.media, 'tracks')), 'recording'), 'disambiguation');
|
||||
|
||||
for (let i = 0, len = comments.length; i < len; i++) {
|
||||
let comment = comments[i];
|
||||
$inputs
|
||||
.eq(i)
|
||||
.val(comment)
|
||||
.data('old', comment);
|
||||
$inputs.eq(i).val(comment).data('old', comment);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
@ -104,7 +97,7 @@ function setRecordingComments() {
|
|||
editing = false,
|
||||
activeRequest = null;
|
||||
|
||||
$('body').on('input.rc', '.recording-comment', function() {
|
||||
$('body').on('input.rc', '.recording-comment', function () {
|
||||
$(this).css('border-color', this.value === $(this).data('old') ? '#999' : 'red');
|
||||
});
|
||||
|
||||
|
@ -112,11 +105,9 @@ function setRecordingComments() {
|
|||
|
||||
$('<button>Edit recording comments</button>')
|
||||
.addClass('styled-button')
|
||||
.on('click', function() {
|
||||
.on('click', function () {
|
||||
editing = !editing;
|
||||
$('#set-recording-comments')
|
||||
.add($inputs)
|
||||
.toggle(editing);
|
||||
$('#set-recording-comments').add($inputs).toggle(editing);
|
||||
$(this).text(`${editing ? 'Hide' : 'Edit'} recording comments`);
|
||||
if (editing) {
|
||||
$('#all-recording-comments').focus();
|
||||
|
@ -153,14 +144,11 @@ function setRecordingComments() {
|
|||
|
||||
$('#set-recording-comments').hide();
|
||||
|
||||
$('#all-recording-comments').on('input', function() {
|
||||
$inputs
|
||||
.filter(':visible')
|
||||
.val(this.value)
|
||||
.trigger('input.rc');
|
||||
$('#all-recording-comments').on('input', function () {
|
||||
$inputs.filter(':visible').val(this.value).trigger('input.rc');
|
||||
});
|
||||
|
||||
var $submitButton = $('#submit-recording-comments').on('click', function() {
|
||||
var $submitButton = $('#submit-recording-comments').on('click', function () {
|
||||
if (activeRequest) {
|
||||
activeRequest.abort();
|
||||
activeRequest = null;
|
||||
|
@ -175,7 +163,7 @@ function setRecordingComments() {
|
|||
let editData = [],
|
||||
deferred = $.Deferred();
|
||||
|
||||
$.each($tracks, function(i, track) {
|
||||
$.each($tracks, function (i, track) {
|
||||
if ($(track).filter(':visible').length > 0) {
|
||||
let $input = $inputs.eq(i),
|
||||
comment = $input.val();
|
||||
|
@ -185,13 +173,10 @@ function setRecordingComments() {
|
|||
}
|
||||
|
||||
deferred
|
||||
.done(function() {
|
||||
$input
|
||||
.data('old', comment)
|
||||
.trigger('input.rc')
|
||||
.prop('disabled', false);
|
||||
.done(function () {
|
||||
$input.data('old', comment).trigger('input.rc').prop('disabled', false);
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
$input.css('border-color', 'red').prop('disabled', false);
|
||||
});
|
||||
|
||||
|
@ -214,15 +199,15 @@ function setRecordingComments() {
|
|||
url: '/ws/js/edit/create',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({ edits: editData, editNote: editNote, makeVotable: makeVotable }),
|
||||
contentType: 'application/json; charset=utf-8'
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
})
|
||||
.always(function() {
|
||||
.always(function () {
|
||||
$submitButton.prop('disabled', false).text('Submit changes (marked red)');
|
||||
})
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
deferred.resolve();
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
deferred.reject();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ var release_attributes = {}; // albumid, total_pages, artist_name, label
|
|||
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() {
|
||||
$(document).ready(function () {
|
||||
LOGGER.info('Document Ready & Takealot Userscript Executing');
|
||||
|
||||
let fmaPage = parseFMApage();
|
||||
|
@ -62,7 +62,7 @@ $(document).ready(function() {
|
|||
// Album detail
|
||||
let retrieve_album_detail = new album_api();
|
||||
|
||||
$.when(retrieve_album_detail).done(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);
|
||||
|
@ -72,7 +72,7 @@ $(document).ready(function() {
|
|||
|
||||
let album_link = window.location.href;
|
||||
|
||||
mblinks.searchAndDisplayMbLink(album_link, 'release', function(link) {
|
||||
mblinks.searchAndDisplayMbLink(album_link, 'release', function (link) {
|
||||
$('div.product-title').after(link);
|
||||
});
|
||||
});
|
||||
|
@ -114,7 +114,7 @@ function insertAPISection() {
|
|||
|
||||
if (DEBUG)
|
||||
fmaUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let fmaStatusBlock = $(
|
||||
|
@ -128,7 +128,7 @@ function insertAPISection() {
|
|||
display: 'inline-block',
|
||||
float: 'left',
|
||||
height: '120px',
|
||||
width: '49%'
|
||||
width: '49%',
|
||||
});
|
||||
|
||||
fmaUI.slideDown();
|
||||
|
@ -136,17 +136,17 @@ function insertAPISection() {
|
|||
|
||||
// Update FreeMusicArchive API Status section on FMA page
|
||||
var updateAPISection = {
|
||||
AlbumId: function(albumid) {
|
||||
AlbumId: function (albumid) {
|
||||
this.albumid = albumid;
|
||||
$('#lbut-lt-fma-api-album-id').text(this.albumid);
|
||||
return 'complete';
|
||||
},
|
||||
ApiKey: function(apikey) {
|
||||
ApiKey: function (apikey) {
|
||||
this.apikey = apikey;
|
||||
$('#lbut-lt-fma-api-key-id').text(FMA_API);
|
||||
return 'complete';
|
||||
},
|
||||
AlbumAjaxStatus: function(ajaxstatus) {
|
||||
AlbumAjaxStatus: function (ajaxstatus) {
|
||||
if (ajaxstatus === null) {
|
||||
this.ajaxstatus = 'notcalled';
|
||||
} else {
|
||||
|
@ -157,23 +157,23 @@ var updateAPISection = {
|
|||
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'
|
||||
'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'
|
||||
'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'
|
||||
'background-color': 'red',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// function to determine if JSON or sub objects exist
|
||||
|
@ -199,7 +199,7 @@ function insertMBSection(release) {
|
|||
).hide();
|
||||
if (DEBUG)
|
||||
mbUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let mbContentBlock = $(
|
||||
|
@ -212,7 +212,7 @@ function insertMBSection(release) {
|
|||
color: 'red',
|
||||
float: 'left',
|
||||
'margin-top': '4px',
|
||||
'margin-bottom': '4px'
|
||||
'margin-bottom': '4px',
|
||||
});
|
||||
mbContentBlock.prepend(warning_buggy);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ function insertMBSection(release) {
|
|||
'background-color': '#eb743b',
|
||||
position: 'absolute',
|
||||
top: '150px',
|
||||
width: '100%'
|
||||
width: '100%',
|
||||
});
|
||||
|
||||
$('form.musicbrainz_import').css({
|
||||
|
@ -256,7 +256,7 @@ function insertMBSection(release) {
|
|||
'text-align': 'center',
|
||||
cursor: 'pointer',
|
||||
'background-color': '#0b79bf',
|
||||
color: '#fefefe'
|
||||
color: '#fefefe',
|
||||
});
|
||||
|
||||
$('form.musicbrainz_import_search').css({
|
||||
|
@ -277,7 +277,7 @@ function insertMBSection(release) {
|
|||
'text-align': 'center',
|
||||
cursor: 'pointer',
|
||||
'background-color': '#0b79bf',
|
||||
color: '#fefefe'
|
||||
color: '#fefefe',
|
||||
});
|
||||
|
||||
/* $('#mb_buttons').css({
|
||||
|
@ -310,7 +310,7 @@ function insertAPIKEYSection() {
|
|||
).hide();
|
||||
if (DEBUG)
|
||||
mbUI.css({
|
||||
border: '1px dotted red'
|
||||
border: '1px dotted red',
|
||||
});
|
||||
|
||||
let mbContentBlock = $('<div class="section_content"></div>');
|
||||
|
@ -328,13 +328,13 @@ function insertAPIKEYSection() {
|
|||
display: 'block',
|
||||
float: 'right',
|
||||
height: '120px',
|
||||
width: '49%'
|
||||
width: '49%',
|
||||
});
|
||||
|
||||
$('#mb_buttons').css({
|
||||
display: 'inline-block',
|
||||
float: 'right',
|
||||
height: '80px'
|
||||
height: '80px',
|
||||
});
|
||||
|
||||
mbUI.slideDown();
|
||||
|
@ -348,10 +348,10 @@ function insertAPIKEYSection() {
|
|||
function album_api() {
|
||||
let fmaWsUrl = `https://api.takealot.com/rest/v-1-6-0/productlines/lookup?idProduct=${release_attributes.albumid}`;
|
||||
|
||||
var promise_variable = $.getJSON(fmaWsUrl, function() {
|
||||
var promise_variable = $.getJSON(fmaWsUrl, function () {
|
||||
updateAPISection.AlbumAjaxStatus('busy');
|
||||
LOGGER.debug(`promise_variable [state] in [getJSON] ${promise_variable.state()}`);
|
||||
}).done(function(albumjson) {
|
||||
}).done(function (albumjson) {
|
||||
LOGGER.debug(' >> Album > DONE');
|
||||
updateAPISection.AlbumAjaxStatus('completed');
|
||||
//LOGGER.debug('Takealot RAW album JSON: ',albumjson);
|
||||
|
@ -443,7 +443,7 @@ function parseFMApage() {
|
|||
// 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) {
|
||||
let m = date.split(/\D+/, 3).map(function (e) {
|
||||
return parseInt(e, 10);
|
||||
});
|
||||
if (m[0] !== undefined) {
|
||||
|
@ -459,7 +459,7 @@ function parse_MM_DD_YYYY(date, obj) {
|
|||
|
||||
function parse_YYYY_MM_DD(date, obj) {
|
||||
if (!date) return;
|
||||
let m = date.split(/\D+/, 3).map(function(e) {
|
||||
let m = date.split(/\D+/, 3).map(function (e) {
|
||||
return parseInt(e, 10);
|
||||
});
|
||||
if (m[0] !== undefined) {
|
||||
|
@ -560,13 +560,13 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
// Release URL
|
||||
fmarelease.urls.push({
|
||||
url: albumobject.uri,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
|
||||
});
|
||||
} else {
|
||||
// Release URL
|
||||
fmarelease.urls.push({
|
||||
url: albumobject.uri,
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order
|
||||
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
//labels
|
||||
if (hasProp(albumobject, 'meta.Label')) {
|
||||
fmarelease.labels.push({
|
||||
name: albumobject.meta.Label
|
||||
name: albumobject.meta.Label,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ function Parsefmarelease(albumobject, trackobject) {
|
|||
let disc = {
|
||||
position: l + 1,
|
||||
format: DiscFormats[fmarelease.disc_format],
|
||||
tracks: disclistarray[l]
|
||||
tracks: disclistarray[l],
|
||||
};
|
||||
fmarelease.discs.push(disc);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue