mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-11-10 13:14:16 +00:00
Refactoring: renamed import_functions lib to mbimport.
This commit is contained in:
parent
116410ad45
commit
a4b23129d0
9 changed files with 57 additions and 57 deletions
|
@ -7,7 +7,7 @@
|
|||
// @updateURL https://raw.github.com/murdos/musicbrainz-userscripts/master/bandcamp_importer.user.js
|
||||
// @include /^https?://[^/]+/(?:album|track)/[^/]+$/
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mblinks.js
|
||||
// @require lib/mbimportstyle.js
|
||||
|
@ -127,7 +127,7 @@ var BandcampImport = {
|
|||
}
|
||||
|
||||
// URLs
|
||||
var link_type = MBReleaseImportHelper.URL_TYPES;
|
||||
var link_type = MBImport.URL_TYPES;
|
||||
// Download for free vs. for purchase
|
||||
if (bandcampAlbumData.current.download_pref !== null) {
|
||||
if (bandcampAlbumData.freeDownloadPage !== null || bandcampAlbumData.current.download_pref === 1 || (
|
||||
|
@ -178,12 +178,12 @@ var BandcampImport = {
|
|||
return false;
|
||||
}
|
||||
// Form parameters
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(release.url, 'Bandcamp');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(release.url, 'Bandcamp');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
// Build form
|
||||
var mbUI = $('<div id="mb_buttons">'
|
||||
+ MBReleaseImportHelper.buildFormHTML(parameters)
|
||||
+ MBReleaseImportHelper.buildSearchButton(release)
|
||||
+ MBImport.buildFormHTML(parameters)
|
||||
+ MBImport.buildSearchButton(release)
|
||||
+ '</div>').hide();
|
||||
|
||||
// Append MB import link
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/beatport_importer.user.js
|
||||
// @include http*://www.beatport.com/release/*
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// ==/UserScript==
|
||||
|
||||
|
@ -79,9 +79,9 @@ function retrieveReleaseInfo() {
|
|||
// Insert button into page under label information
|
||||
function insertLink(release) {
|
||||
var edit_note = 'Imported from ' + window.location.href;
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
var innerHTML = MBReleaseImportHelper.buildFormHTML(parameters);
|
||||
var innerHTML = MBImport.buildFormHTML(parameters);
|
||||
var tr = $("<tr><td span='2' /></tr>");
|
||||
tr.find('td').append(innerHTML);
|
||||
$("table.meta-data tbody").append(tr);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// @include http://pro.beatport.com/release/*
|
||||
// @include https://pro.beatport.com/release/*
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mbimportstyle.js
|
||||
// ==/UserScript==
|
||||
|
@ -54,7 +54,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
// URLs
|
||||
release.urls.push({
|
||||
'url': release_url,
|
||||
'link_type': MBReleaseImportHelper.URL_TYPES.purchase_for_download
|
||||
'link_type': MBImport.URL_TYPES.purchase_for_download
|
||||
});
|
||||
|
||||
release.labels.push(
|
||||
|
@ -92,7 +92,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
title += ' (' + track.mix + ')';
|
||||
}
|
||||
tracks.push({
|
||||
'artist_credit': MBReleaseImportHelper.makeArtistCredits(artists),
|
||||
'artist_credit': MBImport.makeArtistCredits(artists),
|
||||
'title': title,
|
||||
'duration': track.duration.minutes
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
if (unique_artists.length > 4) {
|
||||
unique_artists = [ 'Various Artists' ];
|
||||
}
|
||||
release.artist_credit = MBReleaseImportHelper.makeArtistCredits(unique_artists);
|
||||
release.artist_credit = MBImport.makeArtistCredits(unique_artists);
|
||||
release.discs.push( {
|
||||
'tracks': tracks,
|
||||
'format': release.format
|
||||
|
@ -121,12 +121,12 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
// Insert button into page under label information
|
||||
function insertLink(release, release_url) {
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(release_url, 'BeatPort Pro');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(release_url, 'BeatPort Pro');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
var mbUI = $('<li class="interior-release-chart-content-item musicbrainz-import">'
|
||||
+ MBReleaseImportHelper.buildFormHTML(parameters)
|
||||
+ MBReleaseImportHelper.buildSearchButton(release)
|
||||
+ MBImport.buildFormHTML(parameters)
|
||||
+ MBImport.buildSearchButton(release)
|
||||
+ '</li>').hide();
|
||||
|
||||
$(".interior-release-chart-content-list").append(mbUI);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// @downloadURL https://raw.github.com/murdos/musicbrainz-userscripts/master/cd1d_importer.user.js
|
||||
// @updateURL https://raw.github.com/murdos/musicbrainz-userscripts/master/cd1d_importer.user.js
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mbimportstyle.js
|
||||
// ==/UserScript==
|
||||
|
@ -77,7 +77,7 @@ var CD1DImporter = {
|
|||
var title = row.find('td.tracklist-content-title').text().replace(/^[0-9A-F][0-9]* /, '');
|
||||
return {
|
||||
title: title,
|
||||
duration: MBReleaseImportHelper.hmsToMilliSeconds(duration)
|
||||
duration: MBImport.hmsToMilliSeconds(duration)
|
||||
};
|
||||
}).get();
|
||||
discs.push(disc);
|
||||
|
@ -90,7 +90,7 @@ var CD1DImporter = {
|
|||
var artists = $('div.infos-releasegrp div.list-artist a').map(function () {
|
||||
return $(this).text();
|
||||
}).get();
|
||||
return MBReleaseImportHelper.makeArtistCredits(artists);
|
||||
return MBImport.makeArtistCredits(artists);
|
||||
},
|
||||
|
||||
getAlbum: function () {
|
||||
|
@ -181,7 +181,7 @@ var CD1DImporter = {
|
|||
release.month = releasedate.month;
|
||||
release.day = releasedate.day;
|
||||
|
||||
var link_type = MBReleaseImportHelper.URL_TYPES;
|
||||
var link_type = MBImport.URL_TYPES;
|
||||
|
||||
if (format.name.match(/vinyl|lp/i)) {
|
||||
release.country = 'FR';
|
||||
|
@ -240,13 +240,13 @@ var CD1DImporter = {
|
|||
// Insert links in page
|
||||
|
||||
// Form parameters
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(this.currentURL(), 'CD1D', formatname);
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(this.currentURL(), 'CD1D', formatname);
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
// Build form
|
||||
var mbUI = $('<div id="mb_buttons">'
|
||||
+ MBReleaseImportHelper.buildFormHTML(parameters)
|
||||
+ MBReleaseImportHelper.buildSearchButton(release)
|
||||
+ MBImport.buildFormHTML(parameters)
|
||||
+ MBImport.buildSearchButton(release)
|
||||
+ '</div>').hide();
|
||||
$(where).append(mbUI);
|
||||
$('#mb_buttons').css({'margin-top': '6px'});
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// @exclude http://*.discogs.com/*release/*?f=xml*
|
||||
// @exclude http://www.discogs.com/release/add
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mblinks.js
|
||||
// @require lib/mbimportstyle.js
|
||||
|
@ -135,7 +135,7 @@ function insertMBLinks($root) {
|
|||
mark = entities[mb_type].mark;
|
||||
entity_name = mb_type.replace(/[_-]/g, ' ');
|
||||
}
|
||||
$link.closest('span.mb_wrapper').prepend('<span class="mb_valign mb_searchit"><a class="mb_search_link" target="_blank" title="Search this '+ entity_name + ' on MusicBrainz (open in a new tab)" href="' + MBReleaseImportHelper.searchUrlFor(mb_type, $link.text()) + '"><small>'+mark+'</small>?</a></span>');
|
||||
$link.closest('span.mb_wrapper').prepend('<span class="mb_valign mb_searchit"><a class="mb_search_link" target="_blank" title="Search this '+ entity_name + ' on MusicBrainz (open in a new tab)" href="' + MBImport.searchUrlFor(mb_type, $link.text()) + '"><small>'+mark+'</small>?</a></span>');
|
||||
}
|
||||
var insert_normal = function (link) {
|
||||
$link.closest('span.mb_valign').before('<span class="mb_valign">'+link+'</span>');
|
||||
|
@ -384,13 +384,13 @@ function insertLink(release, current_page_key) {
|
|||
}
|
||||
|
||||
// Form parameters
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(current_page_info.clean_url, 'Discogs');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(current_page_info.clean_url, 'Discogs');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
// Build form + search button
|
||||
var innerHTML = '<div id="mb_buttons">'
|
||||
+ MBReleaseImportHelper.buildFormHTML(parameters)
|
||||
+ MBReleaseImportHelper.buildSearchButton(release)
|
||||
+ MBImport.buildFormHTML(parameters)
|
||||
+ MBImport.buildSearchButton(release)
|
||||
+ '</div>';
|
||||
mbContentBlock.append(innerHTML);
|
||||
|
||||
|
@ -490,7 +490,7 @@ function parseDiscogsRelease(data) {
|
|||
// Release URL
|
||||
release.urls = [];
|
||||
var release_url = getCleanUrl(discogsRelease.uri, 'release');
|
||||
release.urls.push( { url: release_url, link_type: MBReleaseImportHelper.URL_TYPES.discogs } );
|
||||
release.urls.push( { url: release_url, link_type: MBImport.URL_TYPES.discogs } );
|
||||
|
||||
// Release format
|
||||
var release_formats = [];
|
||||
|
@ -566,7 +566,7 @@ function parseDiscogsRelease(data) {
|
|||
var track = new Object();
|
||||
|
||||
track.title = discogsTrack.title;
|
||||
track.duration = MBReleaseImportHelper.hmsToMilliSeconds(discogsTrack.duration); // MB in milliseconds
|
||||
track.duration = MBImport.hmsToMilliSeconds(discogsTrack.duration); // MB in milliseconds
|
||||
|
||||
// Track artist credit
|
||||
track.artist_credit = [];
|
||||
|
@ -600,7 +600,7 @@ function parseDiscogsRelease(data) {
|
|||
return;
|
||||
}
|
||||
if (subtrack.duration) {
|
||||
subtrack_total_duration += MBReleaseImportHelper.hmsToMilliSeconds(subtrack.duration);
|
||||
subtrack_total_duration += MBImport.hmsToMilliSeconds(subtrack.duration);
|
||||
}
|
||||
if (subtrack.title) {
|
||||
subtrack_titles.push(subtrack.title);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// @include http://www.encyclopedisque.fr/disque/*.html
|
||||
// @include http://www.encyclopedisque.fr/artiste/*.html
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/mblinks.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mbimportstyle.js
|
||||
|
@ -35,11 +35,11 @@ $(document).ready(function() {
|
|||
function setupImportUI(release) {
|
||||
|
||||
// Form parameters
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(window.location.href, 'Encyclopedisque');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(window.location.href, 'Encyclopedisque');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
// Build form
|
||||
var mbUI = $(MBReleaseImportHelper.buildFormHTML(parameters) + MBReleaseImportHelper.buildSearchButton(release)).hide();
|
||||
var mbUI = $(MBImport.buildFormHTML(parameters) + MBImport.buildSearchButton(release)).hide();
|
||||
$('#recherchebox').append(mbUI);
|
||||
$('form.musicbrainz_import button').css({width: '100%'});
|
||||
mbUI.slideDown();
|
||||
|
@ -95,7 +95,7 @@ function parseEncyclopedisquePage() {
|
|||
|
||||
// Release URL
|
||||
release.urls = new Array();
|
||||
release.urls.push( { 'url': window.location.href, 'link_type': MBReleaseImportHelper.URL_TYPES.other_databases } );
|
||||
release.urls.push( { 'url': window.location.href, 'link_type': MBImport.URL_TYPES.other_databases } );
|
||||
|
||||
// Parse other infos
|
||||
var releaseInfos = document.body.querySelectorAll("div.main tr");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// @include http*://www.junodownload.com/products/*
|
||||
// @include http*://secure.junodownload.com/products/*
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mbimportstyle.js
|
||||
// ==/UserScript==
|
||||
|
@ -84,7 +84,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
// URLs
|
||||
release.urls.push({
|
||||
'url': release_url,
|
||||
'link_type': MBReleaseImportHelper.URL_TYPES.purchase_for_download
|
||||
'link_type': MBImport.URL_TYPES.purchase_for_download
|
||||
});
|
||||
|
||||
release.labels.push(
|
||||
|
@ -107,7 +107,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
trackname = m[2];
|
||||
}
|
||||
tracks.push({
|
||||
'artist_credit': MBReleaseImportHelper.makeArtistCredits(artists),
|
||||
'artist_credit': MBImport.makeArtistCredits(artists),
|
||||
'title': trackname,
|
||||
'duration': tracklength
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
parsed_release_artist = 'Various Artists';
|
||||
}
|
||||
var release_artists = [ parsed_release_artist ];
|
||||
release.artist_credit = MBReleaseImportHelper.makeArtistCredits(release_artists);
|
||||
release.artist_credit = MBImport.makeArtistCredits(release_artists);
|
||||
release.discs.push( {
|
||||
'tracks': tracks,
|
||||
'format': release.format
|
||||
|
@ -130,12 +130,12 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
// Insert button into page under label information
|
||||
function insertLink(release, release_url) {
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(release_url, 'Juno Download');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(release_url, 'Juno Download');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
var mbUI = $('<div id="mb_buttons">'
|
||||
+ MBReleaseImportHelper.buildFormHTML(parameters)
|
||||
+ MBReleaseImportHelper.buildSearchButton(release)
|
||||
+ MBImport.buildFormHTML(parameters)
|
||||
+ MBImport.buildSearchButton(release)
|
||||
+ '</div>').hide();
|
||||
|
||||
$("div.sociald").before(mbUI);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/lastfm_importer.user.js
|
||||
// @include /^https?:\/\/(?:www\.)?(?:last\.fm|lastfm\.(?:com\.br|com\.tr|at|com|de|es|fr|it|jp|pl|pt|ru|se))\/music\/[^\/]+/[^+][^\/]+/
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @require lib/import_functions.js
|
||||
// @require lib/mbimport.js
|
||||
// @require lib/logger.js
|
||||
// @require lib/mbimportstyle.js
|
||||
// ==/UserScript==
|
||||
|
@ -35,7 +35,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
// Release defaults
|
||||
var release = {
|
||||
artist_credit: MBReleaseImportHelper.makeArtistCredits([artist]),
|
||||
artist_credit: MBImport.makeArtistCredits([artist]),
|
||||
title: $("h1[itemprop='name']").text().trim(),
|
||||
year: 0,
|
||||
month: 0,
|
||||
|
@ -82,7 +82,7 @@ function retrieveReleaseInfo(release_url) {
|
|||
artists = ['[unknown]'];
|
||||
}
|
||||
tracks.push({
|
||||
'artist_credit': MBReleaseImportHelper.makeArtistCredits(artists),
|
||||
'artist_credit': MBImport.makeArtistCredits(artists),
|
||||
'title': trackname,
|
||||
'duration': tracklength
|
||||
});
|
||||
|
@ -99,10 +99,10 @@ function retrieveReleaseInfo(release_url) {
|
|||
|
||||
// Insert button into page under label information
|
||||
function insertLink(release, release_url) {
|
||||
var edit_note = MBReleaseImportHelper.makeEditNote(release_url, 'Last.fm');
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters(release, edit_note);
|
||||
var edit_note = MBImport.makeEditNote(release_url, 'Last.fm');
|
||||
var parameters = MBImport.buildFormParameters(release, edit_note);
|
||||
|
||||
var innerHTML = MBReleaseImportHelper.buildFormHTML(parameters);
|
||||
var innerHTML = MBImport.buildFormHTML(parameters);
|
||||
|
||||
var mbUI = $('<div id="musicbrainz-import">' + innerHTML + '</div>').hide();
|
||||
mbUI.css({'margin-bottom': '6px', 'padding': '2px', 'background-color': '#444', 'text-align': 'center'});
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
*
|
||||
* - First build a release object (see expected format below) that you'll fill in from source of data
|
||||
* - Call as follows, e.g.:
|
||||
* var parameters = MBReleaseImportHelper.buildFormParameters(parsedRelease, optionalEditNote);
|
||||
* var parameters = MBImport.buildFormParameters(parsedRelease, optionalEditNote);
|
||||
* - Then build the HTML that you'll inject into source site page:
|
||||
* var formHtml = MBReleaseImportHelper.buildFormHTML(parameters);
|
||||
* var formHtml = MBImport.buildFormHTML(parameters);
|
||||
* - Addinionally, you can inject a search link to verify that the release is not already known by MusicBrainz:
|
||||
* var linkHtml = MBReleaseImportHelper.buildSearchLink(parsedRelease);
|
||||
* var linkHtml = MBImport.buildSearchLink(parsedRelease);
|
||||
*
|
||||
* Expected format of release object:
|
||||
*
|
||||
|
@ -57,7 +57,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var MBReleaseImportHelper = (function() {
|
||||
var MBImport = (function() {
|
||||
|
||||
// --------------------------------------- publics ----------------------------------------- //
|
||||
|
Loading…
Reference in a new issue