mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-13 20:02:27 +00:00
fixes: header, debug ...
updating header to correct value remove release attributes with empty value remove console.log lines
This commit is contained in:
parent
6df2af1282
commit
640a28dcf9
1 changed files with 17 additions and 95 deletions
|
@ -1,73 +1,13 @@
|
|||
/*
|
||||
- First build a 'release' object that you'll fill in with your source of data
|
||||
|
||||
- Call as follows, e.g.:
|
||||
|
||||
var parameters = MBReleaseImportHelper.buildFormParameters( theParsedRelease, optionalEditNote );
|
||||
|
||||
- Then build the HTML that you'll inject into source site page:
|
||||
|
||||
var formHtml = MBReleaseImportHelper.buildFormHTML( parameters );
|
||||
|
||||
- Addinionally, you can inject a search link to verify that the release is not already known by MusicBrainz:
|
||||
|
||||
var linkHtml = MBReleaseImportHelper.buildSearchLink( theParsedRelease );
|
||||
|
||||
--- 'release' object format : ---
|
||||
|
||||
release = {
|
||||
title,
|
||||
artist_credit = [ { name: '',
|
||||
type,
|
||||
secondary_types = [],
|
||||
status,
|
||||
language,
|
||||
script,
|
||||
packaging,
|
||||
country,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
labels = [ { name, mbid, catno }, ... ],
|
||||
barcode,
|
||||
urls = [ {url, link_type }, ... ],
|
||||
discs = [
|
||||
{
|
||||
title,
|
||||
format,
|
||||
tracks = [
|
||||
{ number, title, duration, artist_credit },
|
||||
...
|
||||
]
|
||||
},
|
||||
...
|
||||
],
|
||||
}
|
||||
|
||||
where 'artist_credit' has the following format:
|
||||
|
||||
artist_credit = [
|
||||
{
|
||||
credited_name,
|
||||
artist_name,
|
||||
artist_mbid,
|
||||
joinphrase
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
// ==UserScript==
|
||||
// @name Import Metal Archives releases into MB
|
||||
// @namespace http://example.com
|
||||
// @version 2015.05.23
|
||||
// @description import d'une release du site metal-archives vers musicbrainz
|
||||
// @downloadURL https://raw.githubusercontent.com/MetalDavidian/Import_Metal_Archives_releases_into_MB/master/Import_Metal_Archives_releases_into_MB.user.js
|
||||
// @update https://raw.githubusercontent.com/MetalDavidian/Import_Metal_Archives_releases_into_MB/master/Import_Metal_Archives_releases_into_MB.user.js
|
||||
// @include http://www.metal-archives.com/albums/*/*/*
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
|
||||
// @require lib/mbimport.js
|
||||
// @name Import Metal Archives releases into MB
|
||||
// @namespace https://github.com/murdos/musicbrainz-userscripts/
|
||||
// @version 2015.08.23.2
|
||||
// @description Add a button on Metal Archives release pages allowing to open MusicBrainz release editor with pre-filled data for the selected release
|
||||
// @downloadURL https://raw.github.com/murdos/musicbrainz-userscripts/master/metalarchives_importer.user.js
|
||||
// @update https://raw.github.com/murdos/musicbrainz-userscripts/master/metalarchives_importer.user.js
|
||||
// @include http://www.metal-archives.com/albums/*/*/*
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
|
||||
// @require https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/lib/mbimport.js
|
||||
// ==/UserScript==
|
||||
$(document).ready(function () {
|
||||
var release = retrieveReleaseInfo();
|
||||
|
@ -84,20 +24,18 @@ function setreleasedate(release, datestring) {
|
|||
release.year = d.getFullYear();
|
||||
release.month = d.getMonth()+1;
|
||||
release.day = d.getDate();
|
||||
console.log(release.day);
|
||||
} else{
|
||||
var d = new Date("2 "+datestring);
|
||||
release.year = d.getFullYear();
|
||||
release.month = d.getMonth()+1;
|
||||
console.log(release.day);
|
||||
}
|
||||
return release;
|
||||
}
|
||||
|
||||
function getGenericalData(){
|
||||
var rdata=new Array();
|
||||
var rdata = new Array();
|
||||
var keydata = $('dl.float_left dt, dl.float_right dt').map(function(){
|
||||
var s=$.trim($(this).text());
|
||||
var s = $.trim($(this).text());
|
||||
return s.substring(0,s.length-1);
|
||||
} ).get();
|
||||
var valuedata= $('dl.float_left dd,dl.float_right dd').map(function(){
|
||||
|
@ -106,12 +44,10 @@ function getGenericalData(){
|
|||
for(i=0;i<keydata.length;i++){
|
||||
rdata[keydata[i]]=valuedata[i];
|
||||
}
|
||||
console.log(rdata);
|
||||
return rdata;
|
||||
}
|
||||
function retrieveReleaseInfo() {
|
||||
var release = new Object();
|
||||
|
||||
release.artist_credit =new Array();
|
||||
release.artist_credit.push({artist_name: $('h2.band_name').text(),credited_name: $('h2.band_name').text()});
|
||||
release.title = $('h1.album_name').text();
|
||||
|
@ -122,21 +58,16 @@ function retrieveReleaseInfo() {
|
|||
//todo add case for multiple labels if such a case exist
|
||||
release.labels = new Array();
|
||||
release.labels.push( {
|
||||
name: (rdata["Label"]== "Independent"?"[no label]":rdata["Label"]),
|
||||
name: (rdata["Label"] == "Independent"?"[no label]":rdata["Label"]),
|
||||
catno: (rdata["Catalog ID"] == "N/A" ? "" :rdata["Catalog ID"])
|
||||
} );
|
||||
|
||||
release.country = ""; // Worldwide
|
||||
|
||||
|
||||
release.type =ReleaseTypes[rdata["Type"]][0];
|
||||
release.secondary_types = new Array(ReleaseTypes[rdata["Type"]][1]);
|
||||
release.status = 'official';
|
||||
|
||||
rdata.hasOwnProperty("Version desc.") && rdata["Version desc."].indexOf("Digipak")!=-1?release.packaging ="Digipak":release.packaging ="";
|
||||
|
||||
rdata.hasOwnProperty("Version desc.") && rdata["Version desc."].indexOf("Digipak")!=-1?release.packaging ="Digipak":release.packaging ="";
|
||||
release.language = '';
|
||||
release.script = '';
|
||||
release.barcode='';
|
||||
var identifiers=$("#album_tabs_notes > div:nth-child(2)").find("p:not([class])").contents();
|
||||
for(var j=0;j<identifiers.length;j++){
|
||||
if(identifiers[j].textContent.indexOf("Barcode:")!=-1){
|
||||
|
@ -144,19 +75,11 @@ function retrieveReleaseInfo() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Release URL
|
||||
release.urls = new Array();
|
||||
release.urls.push( { url: window.location.href, link_type: 82 } );
|
||||
|
||||
// Tracks
|
||||
/*discs = [
|
||||
{
|
||||
title,
|
||||
format,
|
||||
tracks = [
|
||||
{ number, title, duration, artist_credit },
|
||||
...
|
||||
]*/
|
||||
var releaseNumber=1;
|
||||
release.discs = new Array();
|
||||
release.discs.push(new Object());
|
||||
|
@ -164,7 +87,7 @@ function retrieveReleaseInfo() {
|
|||
release.discs[releaseNumber-1].format=ReleaseFormat[rdata["Format"]];
|
||||
var tracksline= $('table.table_lyrics tr.even,table.table_lyrics tr.odd');
|
||||
var trackslinelength=tracksline.length;
|
||||
console.dir(tracksline);
|
||||
|
||||
tracksline.each(function(index,element){
|
||||
var trackNumber= $.trim(element.children[0].textContent).replace('.',"");
|
||||
if( trackNumber == "1" && trackNumber != index+1 ){
|
||||
|
@ -173,7 +96,7 @@ function retrieveReleaseInfo() {
|
|||
release.discs[releaseNumber-1].tracks = new Array();
|
||||
release.discs[releaseNumber-1].format=ReleaseFormat[rdata["Format"]];
|
||||
}
|
||||
console.log(element.children[1]);
|
||||
|
||||
var track = {
|
||||
'number':trackNumber,
|
||||
'title': element.children[1].textContent,
|
||||
|
@ -182,7 +105,6 @@ function retrieveReleaseInfo() {
|
|||
};
|
||||
release.discs[releaseNumber-1].tracks.push(track);
|
||||
});
|
||||
console.log(release);
|
||||
return release;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue