sorry, i forgot all about checking this out. i'm also seeing problems with google even using the last version you posted. i see this in the console:
Thumbs: HTTP error: 0undefined
it's also retrying on some sort of timer which is not good. i'd remove that if i were you. i'm not even going to try and pick apart what you've done. i might take a look if you post an updated common8 version with that template i gave you.
Yes, timer should be changed, i will post script with common8 later.
''0undefined'' mean that you didn't change google domain in properties?
Or your browser redirecting page to use ''http'' instead of ''https'' or something like that?
@mire777
If you port the old script (Biography Photos) to common8 here's a mod that gets artwork from fanart.tv instead of google.
If you like it you can include it in your new script.
// ==PREPROCESSOR==
// @name "Fanart Photos"
// @author "zeremy"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
// Paths
var fbfolder = (fb.ProfilePath + "Artist_fanart");
var lfm_folder = window.GetProperty("Custom folder", fbfolder);
//Image download size
size = window.GetProperty("Download quality","medium");
//Download server
server = window.GetProperty("Download source", "fanart.tv");
//Search terms(google)
terms = window.GetProperty("Custom search terms", "");
//Cycle
cycle2 = window.GetProperty("Image cycle", 10);
//Fanart Type
fanart_type = window.GetProperty("Fanart Type", "musiclogo");
fanart_type_musiclogo_limit = window.GetProperty("Fanart Type - musiclogo", "3");
fanart_type_artistbackground_limit = window.GetProperty("Fanart Type - artistbackground", "0");
fanart_type_cdart_limit = window.GetProperty("Fanart Type - cdart", "0");
fanart_type_albumcover_limit = window.GetProperty("Fanart Type - albumcover", "0");
fanart_type_artistthumb_limit = window.GetProperty("Fanart Type - artistthumb", "0");
fanart_type_musicbanner_limit = window.GetProperty("Fanart Type - musicbanner", "0");
var MF_GRAYED = 0x00000001;
var MF_STRING = 0x00000000;
var IDC_ARROW = 32512;
var IDC_HAND = 32649;
function on_colors_changed() {
p.colors_changed();
}
function on_font_changed() {
//p.font_changed();
}
function on_selection_changed() {
p.item_focus_change();
}
function on_playlist_switch() {
p.item_focus_change();
}
function on_playback_new_track() {
p.item_focus_change();
}
function on_playback_dynamic_info_track() {
p.item_focus_change();
}
function on_playback_stop() {
p.item_focus_change();
}
function on_item_focus_change() {
p.item_focus_change();
}
function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}
//Start Futures
function panel(name, features) {
this.item_focus_change = function() {
if (!this.metadb_func) return;
switch(this.selection_mode) {
case 0:
this.metadb = fb.GetSelection();
break;
case 1:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 2:
this.metadb = fb.GetFocusItem();
break;
}
if (this.metadb) on_metadb_changed();
}
//Size
this.size = function() {
this.w = window.Width;
this.h = window.Height;
}
//Move
this.move = function(x, y) {
this.mx = x;
this.my = y;
}
//Menu
this.rbtn_up = function(x, y) {
var _menu = window.CreatePopupMenu();
var idx;
switch(true) {
case typeof a == "object" && a.trace(x, y):
_menu.AppendMenuItem(MF_STRING, 17, "adjust");
_menu.AppendMenuItem(MF_STRING, 18, "Stretch");
_menu.CheckMenuRadioItem(15, 18, a.type == "centre" ? 15 : a.type == "top" ? 16 : a.type == "adjust" ? 17 : 18);
_menu.AppendMenuSeparator();
break;
case typeof th == "object":
case typeof im == "object" && im.trace(x, y):
var _settings = window.CreatePopupMenu();
var _auto_cycle = window.CreatePopupMenu();
var _download_source = window.CreatePopupMenu();
var _download_limit = window.CreatePopupMenu();
var _download_quality = window.CreatePopupMenu();
var _thumbs = window.CreatePopupMenu();
var _fanart_type = window.CreatePopupMenu();
var MF_POPUP = 0x00000010;
_menu.AppendMenuItem(MF_STRING, 403, "Refresh");
_menu.AppendMenuSeparator();
//Settings Menu
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _settings.ID, "Settings");
_menu.AppendMenuSeparator();
_settings.AppendMenuItem(MF_STRING | MF_POPUP, _auto_cycle.ID, "Auto Cycle");
_auto_cycle.AppendMenuItem(MF_STRING, 415, "05 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 420, "10 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 425, "15 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 430, "20 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 410, "Off");
_auto_cycle.CheckMenuRadioItem(410, 430, cycle2 + 410);
_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_source.ID, "Download Source");
_download_source.AppendMenuItem(MF_STRING, 1902, "Last.fm");
_download_source.AppendMenuItem(MF_STRING, 1903, "fanart.tv");
_download_source.CheckMenuRadioItem(1902, 1904, server == "last.fm" ? 1902 : server == "fanart.tv" ? 1903 : 1903);
_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_limit.ID, "Download Limit");
_download_limit.AppendMenuItem(MF_STRING, 1905, "1x");
_download_limit.AppendMenuItem(MF_STRING, 1906, "2x");
_download_limit.AppendMenuItem(MF_STRING, 1907, "3x");
_download_limit.AppendMenuItem(MF_STRING, 1908, "4x");
_download_limit.AppendMenuItem(MF_STRING, 1909, "5x");
_download_limit.AppendMenuItem(MF_STRING, 1910, "6x");
_download_limit.CheckMenuRadioItem(1905, 1910, im.limit + 1904);
if (server=="last.fm") _settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_quality.ID, "Download Quality");
_download_quality.AppendMenuItem(MF_STRING, 1911, "Low");
_download_quality.AppendMenuItem(MF_STRING, 1912, "Medium");
_download_quality.AppendMenuItem(MF_STRING, 1913, "High");
_download_quality.CheckMenuRadioItem(1911, 1913, size == "low" ? 1911 : size == "medium" ? 1912 : size == "high" ? 1913 : 1913);
if (server=="fanart.tv") _settings.AppendMenuItem(MF_STRING | MF_POPUP, _fanart_type.ID, "Fanart Type");
_fanart_type.AppendMenuItem(MF_STRING, 4000, "Logo");
_fanart_type.AppendMenuItem(MF_STRING, 4001, "Artist Background");
_fanart_type.AppendMenuItem(MF_STRING, 4002, "CD Art");
_fanart_type.AppendMenuItem(MF_STRING, 4003, "Album Cover");
_fanart_type.AppendMenuItem(MF_STRING, 4004, "Artist Thumb");
_fanart_type.AppendMenuItem(MF_STRING, 4005, "Music Banner");
_fanart_type.CheckMenuRadioItem(4000, 4005, fanart_type == "musiclogo" ? 4000 : fanart_type == "artistbackground" ? 4001 : fanart_type == "cdart" ? 4002 : fanart_type == "albumcover" ? 4003 : fanart_type == "artistthumb" ? 4004 : fanart_type == "musicbanner" ? 4005: 4005);
_settings.AppendMenuItem(MF_STRING | MF_POPUP, _thumbs.ID, "Thumbs");
_thumbs.AppendMenuItem(MF_STRING, 1201, "Left");
_thumbs.AppendMenuItem(MF_STRING, 1202, "Right");
_thumbs.AppendMenuItem(MF_STRING, 1203, "Top");
_thumbs.AppendMenuItem(MF_STRING, 1204, "Bottom");
_thumbs.AppendMenuItem(MF_STRING, 1205, "Off");
_thumbs.CheckMenuRadioItem(1200, 1205, th.mode == "grid" ? 1200 : th.mode == "left" ? 1201 : th.mode == "right" ? 1202 : th.mode == "top" ? 1203 : th.mode == "bottom" ? 1204 : 1205);
if (th.mode == "left" | th.mode == "right" | th.mode == "top" | th.mode == "bottom")
{
_thumbs.AppendMenuSeparator();
_thumbs.AppendMenuItem(MF_STRING, 1240, "40px");
_thumbs.AppendMenuItem(MF_STRING, 1250, "50px");
_thumbs.AppendMenuItem(MF_STRING, 1260, "60px");
_thumbs.AppendMenuItem(MF_STRING, 1270, "70px");
_thumbs.AppendMenuItem(MF_STRING, 1280, "80px");
_thumbs.AppendMenuItem(MF_STRING, 1290, "90px");
_thumbs.AppendMenuItem(MF_STRING, 1300, "100px");
_thumbs.AppendMenuItem(MF_STRING, 1350, "150px");
_thumbs.AppendMenuItem(MF_STRING, 1400, "200px");
_thumbs.AppendMenuItem(MF_STRING, 1450, "250px");
_thumbs.AppendMenuItem(MF_STRING, 1500, "300px");
_thumbs.CheckMenuRadioItem(1240, 1500, th.px + 1200);
}
{
_menu.AppendMenuItem(MF_STRING, 400, "Open Folder");
if (server=="last.fm") _menu.AppendMenuItem(MF_STRING, 21, "Open Last.fm");
if (server=="fanart.tv") _menu.AppendMenuItem(MF_STRING, 21, "Open fanart.tv");
//_menu.AppendMenuItem(MF_STRING, 402, "Delete image");
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 405, "Top");
_menu.AppendMenuItem(MF_STRING, 404, "Centre");
_menu.AppendMenuItem(MF_STRING, 406, "Adjust");
_menu.AppendMenuItem(MF_STRING, 407, "Stretch");
_menu.CheckMenuRadioItem(404, 407, im.type == "centre" ? 404 : im.type == "top" ? 405 : im.type == "adjust" ? 406 : 407);
_menu.AppendMenuSeparator();
}
break;
}
if (typeof ps == "object") _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1901, "Last.fm password...");
_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
case 15:
case 16:
case 17:
case 18:
a.type = idx == 15 ? "centre" : idx == 16 ? "top" : idx == 17 ? "adjust" : "stretch";
window.SetProperty("artreader_image_type", a.type);
window.RepaintRect(a.x, a.y, a.w, a.h);
break;
case 21:
if (server=="last.fm") this.browser("http://www.last.fm/music/" + encodeURIComponent(p.artist));
else
if (server=="fanart.tv") this.browser("https://fanart.tv/?s=" + encodeURIComponent(p.artist) + "§=2" + terms);
break;
case 400:
this.run("explorer /select,\"" + im.files[im.index] + "\"");
break;
case 403:
if (im.images.length < im.limit)
{
// p.run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
//fix_limit = im.limit;
im.download();
im.update();
}
else
// p.run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
im.update();
break;
case 404:
case 405:
case 406:
case 407:
im.type = idx == 404 ? "centre" : idx == 405 ? "top" : idx == 406 ? "adjust" : "stretch";
window.SetProperty("Image type", im.type);
window.Repaint();
break;
case 410:
case 415:
case 420:
case 425:
case 430:
cycle2 = idx - 410;
window.SetProperty("Image cycle", cycle2);
cicleTimer = undefined;
cicleTimerStarted = false;
stopTimer();
startTimer();
cicleTimerStarted = true;
break;
case 1200:
case 1201:
case 1202:
case 1203:
case 1204:
case 1205:
th.mode = idx == 1200 ? "grid" : idx == 1201 ? "left" : idx == 1202 ? "right" : idx == 1203 ? "top" : idx == 1204 ? "bottom" : "off";
window.SetProperty("Thumbs mode", th.mode);
th.nc = true;
on_size();
window.Repaint();
break;
case 1240:
case 1250:
case 1260:
case 1270:
case 1280:
case 1290:
case 1300:
case 1350:
case 1400:
case 1450:
case 1500:
th.px = idx - 1200;
window.SetProperty("Thumbs px", th.px);
th.nc = true;
on_size();
window.Repaint();
break;
case 1902:
case 1903:
case 1904:
server = idx == 1902 ? "last.fm" : idx == 1903 ? "fanart.tv" : "fanart.tv";
window.SetProperty("Download source", server);
break;
case 1905:
case 1906:
case 1907:
case 1908:
case 1909:
case 1910:
im.limit = idx - 1904;
window.SetProperty("Download limit", im.limit);
break;
case 1911:
case 1912:
case 1913:
size = idx == 1911 ? "low" : idx == 1912 ? "medium" : idx == 1913 ? "high" : "high";
window.SetProperty("Download quality", size);
break;
case 4000:
case 4001:
case 4002:
case 4003:
case 4004:
case 4005:
fanart_type = idx == 4000 ? "musiclogo" : idx == 4001 ? "artistbackground" : idx == 4002 ? "cdart" : idx == 4003 ? "albumcover" : idx == 4004 ? "artistthumb" : idx == 4005 ? "musicbanner" : "musicbanner";
window.SetProperty("Fanart Type", fanart_type);
im.update();
window.Repaint();
break;
}
_menu.Dispose();
}
//Futures Init
this.features_init = function() {
for (i = 0; i < this.features.length; i++) {
switch(this.features[i]) {
case "metadb":
this.selection_mode = window.GetProperty("Selection mode", 1);
break;
case "remap":
this.artist_tf = window.GetProperty("Artist format", "%artist%");
break;
}}}
//Check Future
this.check_feature = function(f) {
for (i = 0; i < this.features.length; i++) {
if (this.features[i] == f) return true;
}
return false;
}
//Eval Title/Format
this.eval = function(tf) {
if (!this.metadb || tf == "") return "";
if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
return fb.TitleFormat(tf).Eval();
} else {
return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
}}
//Console
this.console = function(message) {
fb.trace(this.name + ": " + message);
}
//Msg Box
this.MsgBox = function(prompt, buttons, title) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
}
//Open In Browser
this.browser = function(command) {
if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, this.name);
}
//Run Command
this.run = function(command) {
try {
this.WshShell.Run(command);
return true;
} catch(e) {
return false;
}}
//Display Image
this.draw_image = function(gr, img, pos_x, pos_y, width, height, type, border, alpha) {
if (!img) return;
gr.SetInterpolationMode(7);
switch(type) {
case "centre":
case "top":
{
var sr = img.Width / img.Height;
var dr = width / height;
if (sr < dr) {
var r = img.Width / width;
var ch = height * r;
var sy = Math.round((img.Height - ch) / (type == "top" ? 1000 : 2));
var cw = img.Width;
var sx = 0;
} else {
var r = img.Height / height;
var cw = width * r;
var sx = Math.round((img.Width - cw) / 2);
var ch = img.Height;
var sy = 0;
}
{
gr.DrawImage(img, pos_x, pos_y, width, height, sx + 5, sy + 5, cw - 10, ch - 10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
}
}
break;
case "stretch":
//strech
gr.DrawImage(img, pos_x, pos_y, width, height, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
break;
case "adjust":
default:
//adjust
var s = Math.min(width / img.Width, height / img.Height);
var nw = Math.round(img.Width * s);
var nh = Math.round(img.Height * s);
pos_x += Math.round((width - nw) / 2);
pos_y += Math.round((height - nh) / 2);
gr.DrawImage(img, pos_x, pos_y, nw, nh, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, nw - 1, nh - 1, 1, border);
break;
}
}
//Remove false string from file names
this.clean_filename = function(filename) {
return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_');
}
this.name = "Fanart.tv";
this.features = features;
this.dui = window.InstanceType;
this.script_path = fb.ProfilePath;
this.w = 0;
this.h = 0;
this.mx = 0;
this.my = 0;
this.metadb = fb.GetFocusItem();
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.data_folder = lfm_folder + "\\";
if (lfm_folder==fb.ProfilePath + "Artist_fanart") if (!this.fso.FolderExists(this.data_folder)) this.fso.CreateFolder(this.data_folder), this.data_folder=this.data_folder;
if (!this.fso.FolderExists(this.data_folder)) return;
this.artist = "";
this.artist_tf = "%artist%";
this.metadb_func = typeof on_metadb_changed == "function";
this.features_init();
}
function artreader(x, y, w, h) {
this.draw = function(gr) {
if (!this.img) return;
p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, this.type);
}
this.trace = function(x, y) {
return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
}
this.wheel = function(step) {
if (!this.trace(p.mx, p.my)) return false;
this.id -= step;
if (this.id < 0) this.id = 4;
if (this.id > 4) this.id = 0;
window.SetProperty("artreader_id", this.id);
this.metadb_changed();
return true;
}
this.move = function(x, y) {
if (this.trace(x, y)) {
if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
return true;
} else {
p.ttd();
return false;
}}
this.lbtn_dblclk = function(x, y) {
if (!this.trace(x, y)) return false;
if (this.img) p.run("explorer /select,\"" + this.path + "\"");
return true;
}
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.img = null;
this.path = null;
}
function images(x, y, w, h) {
this.playback_time = function(time) {
}
this.draw = function (gr) {
if (this.images.length == 0) return;
p.draw_image(gr, this.images[this.index], this.x, this.y, this.w, this.h, this.type);
}
//MetaDB
this.metadb_changed = function() {
if (!p.metadb) return false;
switch(this.mode) {
case "last.fm":
p.artist = p.eval(p.artist_tf);
if (this.artist == p.artist) return false;
this.artist = p.artist;
this.folder = p.data_folder + p.clean_filename(p.artist);
if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
break;
}
this.update();
return true;
}
this.trace = function(x, y) {
return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
}
this.wheel = function(step) {
if (!p.metadb || this.images.length < 2 || !this.trace(p.mx, p.my) || (typeof th == "object" && th.mode == "grid" && !th.overlay)) return false;
this.index -= step;
if (this.index < 0) this.index = this.images.length - 1;
if (this.index >= this.images.length) this.index = 0;
window.RepaintRect(this.x, this.y, this.w, this.h);
return true;
}
//Db-Click
this.lbtn_dblclk = function(x, y) {
if (!this.trace(x, y)) return false;
p.run("\"" + this.files[this.index] + "\"");
return true;
}
//Download Image
this.download = function()
{
if (!p.fso.FolderExists(this.folder)) return;
{
if (server=="last.fm")
{{
this.working=true;
if (p.artist == "" || p.artist == "?") return;
var folder = this.folder + "\\";
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/+images", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (im.xmlhttp.readyState == 4) {
if (im.xmlhttp.status == 200) {
var text = im.xmlhttp.responsetext;
if (!im.doc) im.doc = new ActiveXObject("htmlfile");
im.doc.open();
var div = im.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("img");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].src.indexOf("http://userserve-ak.last.fm/serve/126s") == 0) urls.push(data[i].src.replace("126s", size == "low" ? "252" : size == "medium" ? "500" : size == "high" ? "_" : "_"));
}
fix_limit = im.limit;
for (i = 0; i < Math.min(urls.length, fix_limit, 50); i++) {
p.WshShell.Run("cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + urls[i] + "\" \"" + [folder + p.clean_filename(p.artist) + "_" + i] + urls[i].substring(urls[i].lastIndexOf("/")+1000) + ".jpg" + "\"" , 0, true);
if (im.images.length == 0) {im.update(); fix_limit = im.limit+1;}
if (im.images.length == 0) {return;}
}
im.doc.close();
im.working=false;
im.update();
window.NotifyOthers("images", "update");
} else {
p.console("HTTP error: " + im.xmlhttp.status);
}}}}}
else
if (server=="fanart.tv")
{{
this.working=true;
if (p.artist == "" || p.artist == "?") return;
var folder = this.folder + "\\";
//get mbid from wsh_data folder.
p.data_folder2 = fb.ProfilePath + "wsh_data\\";
p.artists_folder2 = p.data_folder2 + "artists\\";
var fn1 = p.artists_folder2 + p.eval("%artist%") + "\\musicbrainz_artistid.txt";
musicbrainz_id = p.eval("$if3(%musicbrainz_artistid%,%musicbrainz artist id%,)");
musicbrainz_id = musicbrainz_id.substring(0, 36);
p.console(fn1);
musicbrainz_id = utils.ReadTextFile(fn1);
p.console(p.eval("%artist%"));
p.console(musicbrainz_id);
fanart = "https://fanart.tv/artist/" + musicbrainz_id;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", fanart, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (im.xmlhttp.readyState == 4) {
if (im.xmlhttp.status == 200) {
var text = im.xmlhttp.responsetext;
if (!im.doc) im.doc = new ActiveXObject("htmlfile");
im.doc.open();
var div = im.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls_musiclogo = [];
var urls_artistbackground = [];
var urls_cdart = [];
var urls_albumcover = [];
var urls_artistthumb = [];
var urls_musicbanner = [];
p.console(fanart);
//hdmusiclogo, musiclogo, artistbackground, cdart, albumcover, artistthumb, musicbanner
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("musiclogo") > 0) urls_musiclogo.push(data[i]);
}
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("artistbackground") > 0) urls_artistbackground.push(data[i]);
}
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("cdart") > 0) urls_cdart.push(data[i]);
}
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("albumcover") > 0) urls_albumcover.push(data[i]);
}
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("artistthumb") > 0) urls_artistthumb.push(data[i]);
}
for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("musicbanner") > 0) urls_musicbanner.push(data[i]);
}
fix_limit = im.limit;
//no of urls
p.console("Fanart.tv results");
p.console("urls_musiclogo: " + urls_musiclogo.length);
p.console("urls_artistbackground: " + urls_artistbackground.length);
p.console("urls_cdart: " + urls_cdart.length);
p.console("urls_albumcover: " + urls_albumcover.length);
p.console("urls_artistthumb: " + urls_artistthumb.length);
p.console("urls_musicbanner: " + urls_musicbanner.length);
p.console("Downloading From Fanart.tv Started");
//musiclogo
fix_limit = fanart_type_musiclogo_limit;
for (i = 0; i < Math.min(urls_musiclogo.length, fix_limit, 50); i++) {
urls_musiclogo[i] = decodeURIComponent(urls_musiclogo[i]).replace("about:", "https://fanart.tv");
image_ext = urls_musiclogo[i].substr(urls_musiclogo[i].lastIndexOf('.') + 1);
image_name = urls_musiclogo[i].substr(urls_musiclogo[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_musiclogo[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_musiclogo[i]) + "\" \"" + folder + "\musiclogo-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
//artistbackground
fix_limit = fanart_type_artistbackground_limit;
for (i = 0; i < Math.min(urls_artistbackground.length, fix_limit, 50); i++) {
urls_artistbackground[i] = decodeURIComponent(urls_artistbackground[i]).replace("about:", "https://fanart.tv");
image_ext = urls_artistbackground[i].substr(urls_artistbackground[i].lastIndexOf('.') + 1);
image_name = urls_artistbackground[i].substr(urls_artistbackground[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_artistbackground[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_artistbackground[i]) + "\" \"" + folder + "\artistbackground-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
//cdart
fix_limit = fanart_type_cdart_limit;
for (i = 0; i < Math.min(urls_cdart.length, fix_limit, 50); i++) {
urls_cdart[i] = decodeURIComponent(urls_cdart[i]).replace("about:", "https://fanart.tv");
image_ext = urls_cdart[i].substr(urls_cdart[i].lastIndexOf('.') + 1);
image_name = urls_cdart[i].substr(urls_cdart[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_cdart[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_cdart[i]) + "\" \"" + folder + "\cdart-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
//albumcover
fix_limit = fanart_type_albumcover_limit;
for (i = 0; i < Math.min(urls_albumcover.length, fix_limit, 50); i++) {
urls_albumcover[i] = decodeURIComponent(urls_albumcover[i]).replace("about:", "https://fanart.tv");
image_ext = urls_albumcover[i].substr(urls_albumcover[i].lastIndexOf('.') + 1);
image_name = urls_albumcover[i].substr(urls_albumcover[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_albumcover[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_albumcover[i]) + "\" \"" + folder + "\albumcover-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
//artistthumb
fix_limit = fanart_type_artistthumb_limit;
for (i = 0; i < Math.min(urls_artistthumb.length, fix_limit, 50); i++) {
urls_artistthumb[i] = decodeURIComponent(urls_artistthumb[i]).replace("about:", "https://fanart.tv");
image_ext = urls_artistthumb[i].substr(urls_artistthumb[i].lastIndexOf('.') + 1);
image_name = urls_artistthumb[i].substr(urls_artistthumb[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_artistthumb[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_artistthumb[i]) + "\" \"" + folder + "\artistthumb-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
//musicbanner
fix_limit = fanart_type_musicbanner_limit;
for (i = 0; i < Math.min(urls_musicbanner.length, fix_limit, 50); i++) {
urls_musicbanner[i] = decodeURIComponent(urls_musicbanner[i]).replace("about:", "https://fanart.tv");
image_ext = urls_musicbanner[i].substr(urls_musicbanner[i].lastIndexOf('.') + 1);
image_name = urls_musicbanner[i].substr(urls_musicbanner[i].lastIndexOf('/') + 1);
p.console("Downloading..: " + urls_musicbanner[i]);
cmd = "cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls_musicbanner[i]) + "\" \"" + folder + "\musicbanner-" + image_name + "\"" ;
p.console(cmd);
p.WshShell.Run(cmd, 0, true);
if (im.images.length == 0) {fix_limit = im.limit+1; im.update();}
if (im.images.length == 0) {return;}
}
p.console("Downloading From Fanart.tv Finished");
im.doc.close();
im.working=false;
im.update();
window.NotifyOthers("images", "update");
} else {
p.console("HTTP error: " + im.xmlhttp.status + urls);
}}}}}}}
this.update = function() {
this.index = 0;
for (i = 0; i < this.images.length; i++) {
try { this.images[i].Dispose(); } catch(e) {}
}
this.folders = this.folder.split("|");
this.files = [];
for (i = 0; i < this.folders.length; i++) {
if (p.fso.FolderExists(this.folders[i])) this.files = this.files.concat(utils.Glob(this.folders[i] + "\\" + fanart_type + "*.jpg").toArray(), utils.Glob(this.folders[i] + "\\" + fanart_type + "*.jpeg").toArray(), utils.Glob(this.folders[i] + "\\" + fanart_type + "*.png").toArray(), utils.Glob(this.folders[i] + "\\" + fanart_type + "*.gif").toArray());
}
p.console("Current Image Set: " + this.files);
this.images = [];
for (i = 0; i < this.files.length; i++) {
this.images[i] = gdi.Image(this.files[i]);
}
if (typeof th == "object") {
th.nc = true;
th.calc();
}
window.Repaint();
}
//Delete Image
this.delete_image = function() {
if (!this.app) this.app = new ActiveXObject("Shell.Application");
this.app.Namespace(10).MoveHere(this.files[this.index]);
window.SetTimeout(function() {
im.update();
window.NotifyOthers("images", "update");
}, 100);
}
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.files = [];
this.images = [];
this.index = 0;
this.artist = "";
this.folder = "";
this.limit = window.GetProperty("Download limit", 6);
this.mode = ("last.fm");
this.type = window.GetProperty("Image type", "adjust");
this.auto_download = window.GetProperty("Download [on/off]", "on");
}
//Thumbs
function thumbs() {
this.trace = function(x, y) {
return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
}
this.draw = function(gr) {
switch(true) {
case im.images.length == 0:
break;
case this.mode == "off":
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
case !this.img:
break;
case this.mode == "grid":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
if (this.overlay) {
gr.FillSolidRect(this.x, this.y, this.w, this.h, RGBA(0, 0, 0, 126));
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, "adjust");
}
break;
case this.mode == "left":
case this.mode == "right":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
case this.mode == "bottom":
case this.mode == "top":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, this.offset * this.px, 0, this.w, this.h);
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
}}
this.calc = function() {
this.offset = 0;
switch(true) {
case p.w < this.px || p.h < this.px || this.mode == "off":
this.nc = true;
this.img && this.img.Dispose();
this.img = null;
im.x = 0;
im.y = 0;
im.w = p.w;
im.h = p.h;
break;
case this.mode == "grid":
this.x = 0;
this.y = 0;
this.w = p.w;
this.h = p.h;
im.x = 40;
im.y = 40;
im.w = this.w - 80;
im.h = this.h - 80;
if (!this.nc && this.columns != Math.floor(this.w / this.px)) this.nc = true;
this.overlay = false;
this.rows = Math.ceil(this.h / this.px);
this.columns = Math.floor(this.w / this.px);
this.img_rows = Math.ceil(im.images.length / this.columns);
if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(Math.min(this.columns, im.images.length) * this.px, this.img_rows * this.px);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
var ci = 0;
var row, col;
for (row = 0; row < this.img_rows; row++) {
for (col = 0; col < this.columns; col++) {
if (ci == im.images.length) continue;
p.draw_image(temp_gr, im.images[ci], col * this.px, row * this.px, this.px, this.px, "top");
ci++;
}}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
case this.mode == "left":
case this.mode == "right":
this.x = this.mode == "left" ? 0 : p.w - this.px;
this.y = 0;
this.w = this.px;
this.h = p.h;
im.x = this.mode == "right" ? 0 : this.px;
im.y = 0;
im.w = p.w - this.px;
im.h = p.h;
this.rows = Math.ceil(this.h / this.px);
if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(this.px, this.px * im.images.length);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
for (i = 0; i < im.images.length; i++) {
p.draw_image(temp_gr, im.images[i], 0, i * this.px, this.px, this.px, "top");
}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
case this.mode == "bottom":
case this.mode == "top":
this.x = 0;
this.y = this.mode == "top" ? 0 : p.h - this.px;
this.w = p.w;
this.h = this.px;
im.x = 0;
im.y = this.mode == "bottom" ? 0 : this.px;
im.w = p.w;
im.h = p.h - this.px;
this.columns = Math.ceil(this.w / this.px);
if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(this.px * im.images.length, this.px);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
for (i = 0; i < im.images.length; i++) {
p.draw_image(temp_gr, im.images[i], i * this.px, 0, this.px, this.px, "top");
}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
}}
this.wheel = function(step) {
switch(true) {
case !this.trace(p.mx, p.my):
case this.overlay:
return false;
case this.mode == "grid":
if (this.img_rows < this.rows) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.offset > this.img_rows - this.rows) this.offset = this.img_rows - this.rows + 1;
break;
case this.mode == "left":
case this.mode == "right":
if (im.images.length < this.rows) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.rows + this.offset > im.images.length) this.offset = im.images.length - this.rows + 1;
break;
case this.mode == "bottom":
case this.mode == "top":
if (im.images.length < this.columns) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.columns + this.offset > im.images.length) this.offset = im.images.length - this.columns + 1;
break;
}
window.RepaintRect(this.x, this.y, this.w, this.h);
return true;
}
this.move = function(x, y) {
switch(true) {
case !this.trace(x, y):
window.SetCursor(IDC_ARROW);
return false;
case this.overlay:
window.SetCursor(IDC_ARROW);
return true;
case this.mode == "grid":
this.index = Math.floor((x - this.x) / this.px) + (Math.floor((y - this.y) / this.px) * this.columns) + (this.offset * this.columns);
break;
case this.mode == "left":
case this.mode == "right":
this.index = Math.floor((y - this.y) / this.px) + this.offset;
break;
case this.mode == "bottom":
case this.mode == "top":
this.index = Math.floor((x - this.x) / this.px) + this.offset;
break;
}
window.SetCursor(this.index < im.images.length ? IDC_HAND : IDC_ARROW);
return true;
}
this.lbtn_up = function(x, y) {
switch(true) {
case !this.trace(x, y):
return false;
case this.mode == "grid" && this.overlay && im.trace(x, y):
this.overlay = false;
window.Repaint();
break;
case this.mode == "grid" && this.index < im.images.length && !this.overlay:
this.overlay = true;
im.index = this.index;
window.Repaint();
break;
case this.overlay:
break;
case this.index < im.images.length:
im.index = this.index;
window.Repaint();
}
return true;
}
this.lbtn_dblclk = function(x, y) {
if (!im.trace(x, y) || th.mode == "grid") return false;
p.run("\"" + im.files[im.index] + "\"");
return true;
}
this.nc = false;
this.mode = window.GetProperty("Thumbs mode", p.check_feature("now_playing") ? "off" : "off");
this.px = window.GetProperty("Thumbs px", 40);
this.img = null;
}
//START---->
var p = new panel("Thumbs", ["remap", "metadb"]);
var im = new images(0, 0, 0, 0);
var th = new thumbs();
on_item_focus_change();
function on_playback_time(time) {
im.playback_time(time);
}
function on_size() {
p.size();
th.calc();
}
function on_paint(gr) {
col = utils.GetSysColor(1);
gr.FillSolidRect(0, 0, p.w, p.h, col);
th.draw(gr);
}
function on_metadb_changed() {
im.metadb_changed();
window.SetTimeout(function()
{
if (im.images.length == 0 && im.auto_download=="on")
im.download();
}, 5000);
}
function on_mouse_wheel(step) {
if (th.wheel(step)) return;
if (im.wheel(step)) return;
}
function on_mouse_move(x, y) {
p.move(x, y);
th.move(x, y);
}
function on_mouse_lbtn_up(x, y) {
th.lbtn_up(x, y);
}
function on_mouse_lbtn_dblclk(x, y) {
th.lbtn_dblclk(x, y);
}
//Auto Cycle Image
var cicleTimerStarted = false;
var cicleTimer = null;
(function startTimer(){
if(!cicleTimerStarted){
cicleTimer = window.CreateTimerInterval(cycle2+"000");
cicleTimerStarted = true;
}
})();
function stopTimer(){
if(!cicleTimerStarted) return;
window.KillTimer(cicleTimer);
cicleTimer = undefined;
cicleTimerStarted = false;
}
function on_timer(id) {
if(cicleTimer && id == cicleTimer.ID){
{
do{
im.index++
if (im.index == im.images.length) im.index=0;
window.Repaint();
}while (im.index==-1);
}}}