Seems to be MusicBrainz_IDs
I see.
Doesn't it make more sense to wait a little while for foo_musicbrainz to get this extended API support? Maybe through a pull request, if MordredKLB is open to it and does not have the time to write the code?
Otherwise there will be a lot of extra plumbing code to maintain just to do the fanart.tv calls...
Musicbrainz tagging is a manual process , that a user has to do to get the id's. I dont believe adding fanart calls to the component would be "automatic"
@TT
I used the following in a theme I created back in 2018 called Project2018, I just tested it and it still works (the fanarts api hasn't changed) , if you want a hint to add to Reborn.
_.mixin({
fanarttv: function () {
this.get = function (method, metadb) {
if (!metadb || !this.api_key || !this.client_key)
return;
var artist = fb.TitleFormat("$meta(artist,0)").EvalWithMetadb(metadb);
var musicbrainz_artistid = fb.TitleFormat("$if3($meta(musicbrainz_artistid,0),$meta(musicbrainz artist id,0),0)").EvalWithMetadb(metadb);
var musicbrainz_releasegroupid = fb.TitleFormat("$if3($meta(musicbrainz_releasegroupid,0),$meta(musicbrainz release group id,0),0)").EvalWithMetadb(metadb);
if (musicbrainz_releasegroupid == 0 && method == "cover") {
this.console(method + ": " + "Musicbrainz Release ID is missing.");
return;
}
if (musicbrainz_releasegroupid == 0 && method == "disc") {
this.console(method + ": " + "Musicbrainz Release ID is missing.");
return;
}
if (musicbrainz_artistid == 0 && method == "musiclogo") {
this.console(method + ": " + "Musicbrainz Artist ID is missing.");
return;
}
if (musicbrainz_artistid == 0 && method == "artistbackground") {
this.console(method + ": " + "Musicbrainz Artist ID is missing.");
return;
}
if (musicbrainz_artistid == 0 && method == "artistthumb") {
this.console(method + ": " + "Musicbrainz Artist ID is missing.");
return;
}
var path = fb.TitleFormat("$directory_path(%path%)").EvalWithMetadb(metadb);
var cover_files = utils.Glob(path + "\\cover.*").toArray();
var disc_files = utils.Glob(path + "\\disc.*").toArray();
var musiclogo_files = utils.Glob(_.artistFolder(artist) + "musiclogo\\*.*").toArray();
var artistbackground_files = utils.Glob(_.artistFolder(artist) + "artistbackground\\*.*").toArray();
var artistthumb_files = utils.Glob(_.artistFolder(artist) + "artistthumb\\*.*").toArray();
if (method == "cover" && cover_files.length >= this.cover_limit)
return;
if (method == "disc" && disc_files.length >= this.disc_limit)
return;
if (method == "musiclogo" && musiclogo_files.length >= this.musiclogo_limit)
return;
if (method == "artistbackground" && artistbackground_files.length >= this.artistbackground_limit)
return;
if (method == "artistthumb" && artistthumb_files.length >= this.artistthumb_limit)
return;
if (method == "cover" || method == "disc")
var url = this.get_base_url() + "albums/" + musicbrainz_releasegroupid + '?api_key=' + this.api_key + '&client_key=' + this.client_key;
else if (method == "musiclogo" || method == "artistbackground" || method == "artistthumb")
var url = this.get_base_url() + musicbrainz_artistid + '?api_key=' + this.api_key + '&client_key=' + this.client_key;
var xmlhttp = new ActiveXObject('Msxml2.XMLHTTP.6.0');
xmlhttp.open('GET', url, true);
xmlhttp.setRequestHeader('User-Agent', this.ua);
xmlhttp.onreadystatechange = _.bind(function () {
if (xmlhttp.readyState == 4) {
switch (true) {
case xmlhttp.status == 200:
var data = xmlhttp.responseText;
var json_data = _.jsonParse(data);
try {
if (method == "cover") {
var cover_data = [];
var cover = json_data['albums'][musicbrainz_releasegroupid]['albumcover'] || [];
if (cover.length && cover.length > cover_files.length) {
cover_data.push.apply(cover_data, cover);
for (i = 0; i < Math.min(cover_data.length, this.cover_limit); i++) {
image_url = cover_data[i].url;
image_name = cover_data[i].url.substr(cover_data[i].url.lastIndexOf('/') + 1);
image_ext = cover_data[i].url.substr(cover_data[i].url.lastIndexOf('.') + 1);
cmd = "cscript //nologo \"" + this.download_vbs + "\" \"" + decodeURIComponent(cover_data[i].url) + "\" \"" + path + "\\cover." + image_ext + "\"";
this.console(cmd);
_.runCmd(cmd, false);
}
}
}
if (method == "disc") {
var disc_data = [];
var disc = json_data['albums'][musicbrainz_releasegroupid]['cdart'] || [];
if (disc.length && disc.length > disc_files.length) {
disc_data.push.apply(disc_data, disc);
for (i = 0; i < Math.min(disc_data.length, this.disc_limit); i++) {
image_url = disc_data[i].url;
image_name = disc_data[i].url.substr(disc_data[i].url.lastIndexOf('/') + 1);
image_ext = disc_data[i].url.substr(disc_data[i].url.lastIndexOf('.') + 1);
cmd = "cscript //nologo \"" + this.download_vbs + "\" \"" + decodeURIComponent(disc_data[i].url) + "\" \"" + path + "\\disc." + image_ext + "\"";
this.console(cmd);
_.runCmd(cmd, false);
}
}
}
if (method == "musiclogo") {
var musiclogo_data = [];
var musiclogo = json_data['hdmusiclogo'] || [];
if (musiclogo.length && musiclogo.length > musiclogo_files.length) {
musiclogo_data.push.apply(musiclogo_data, musiclogo);
for (i = 0; i < Math.min(musiclogo_data.length, this.musiclogo_limit); i++) {
image_url = musiclogo_data[i].url;
image_name = musiclogo_data[i].url.substr(musiclogo_data[i].url.lastIndexOf('/') + 1);
_.createFolder(_.artistFolder(artist) + "musiclogo\\");
cmd = "cscript //nologo \"" + this.download_vbs + "\" \"" + decodeURIComponent(musiclogo_data[i].url) + "\" \"" + _.artistFolder(artist) + "musiclogo\\" + image_name + "\"";
this.console(cmd);
_.runCmd(cmd, false);
}
}
}
if (method == "artistbackground") {
var artistbackground_data = [];
var artistbackground = json_data['artistbackground'] || [];
if (artistbackground.length && artistbackground.length > artistbackground_files.length) {
artistbackground_data.push.apply(artistbackground_data, artistbackground);
for (i = 0; i < Math.min(artistbackground_data.length, this.artistbackground_limit); i++) {
image_url = artistbackground_data[i].url;
image_name = artistbackground_data[i].url.substr(artistbackground_data[i].url.lastIndexOf('/') + 1);
_.createFolder(_.artistFolder(artist) + "artistbackground\\");
cmd = "cscript //nologo \"" + this.download_vbs + "\" \"" + decodeURIComponent(artistbackground_data[i].url) + "\" \"" + _.artistFolder(artist) + "artistbackground\\" + image_name + "\"";
this.console(cmd);
_.runCmd(cmd, false);
}
}
}
if (method == "artistthumb") {
var artistthumb_data = [];
var artistthumb = json_data['artistthumb'] || [];
if (artistthumb.length && artistthumb.length > artistthumb_files.length) {
artistthumb_data.push.apply(artistthumb_data, artistthumb);
for (i = 0; i < Math.min(artistthumb_data.length, this.artistthumb_limit); i++) {
image_url = artistthumb_data[i].url;
image_name = artistthumb_data[i].url.substr(artistthumb_data[i].url.lastIndexOf('/') + 1);
_.createFolder(_.artistFolder(artist) + "artistthumb\\");
cmd = "cscript //nologo \"" + this.download_vbs + "\" \"" + decodeURIComponent(artistthumb_data[i].url) + "\" \"" + _.artistFolder(artist) + "artistthumb\\" + image_name + "\"";
this.console(cmd);
_.runCmd(cmd, false);
}
}
}
} catch (err) {
this.console(method + ": " + 'None Found');
}
break;
default:
this.console('HTTP error: ' + xmlhttp.status);
xmlhttp.responseText && console.log(xmlhttp.responseText);
this.console(method + ": " + 'HTTP error: ' + xmlhttp.status);
break;
}
}
}, this);
xmlhttp.send();
}
this.get_base_url = function () {
return 'http://webservice.fanart.tv/v3/music/';
}
this.console = function (msg) {
console.log("Fanarttv: " + msg);
}
this.api_key = window.GetProperty('Fanarttv API Key', "");
this.client_key = window.GetProperty('Fanarttv Client Key', "");
this.ua = 'foo_jscript_panel_fanarttv';
this.enabled = window.GetProperty('Fanarttv Auto Download', true);
this.auto_cover = window.GetProperty('Fanarttv Auto Download Cover', false);
this.auto_disc = window.GetProperty('Fanarttv Auto Download Disc', false);
this.auto_musiclogo = window.GetProperty('Fanarttv Auto Download Musiclogo', true);
this.auto_artistbackground = window.GetProperty('Fanarttv Auto Download ArtistBackground', true);
this.auto_artistthumb = window.GetProperty('Fanarttv Auto Download ArtistThumb', true);
this.cover_limit = 1;
this.disc_limit = 1;
this.musiclogo_limit = window.GetProperty('Fanarttv Musiclogo Limit', 3);
this.artistbackground_limit = window.GetProperty('Fanarttv ArtistBackground Limit', 1);
this.artistthumb_limit = window.GetProperty('Fanarttv ArtistThumb Limit', 3);
this.download_vbs = fb.ComponentPath + "samples\\complete\\vbs\\download.vbs";
}
});