Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod script discussion/help (Read 1403523 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #3426
i'll take a look at the spotify api later. i'm assuming it will be well populated with useful stuff.

WSH Panel Mod script discussion/help

Reply #3427
Does someone know some other biography site beside wiki and last.fm?
I try to use MTV bio, but they don't have a huge database..

http://www.artistdirect.com/artist/bio/korn/516409
http://allmusic.com/artist/korn-mn0000112789/biography
http://www.rollingstone.com/music/artists/korn
https://music.yahoo.com/artist/korn/
http://beta.musicbrainz.org/artist/ac865b2...56-dd40d5e39f46
http://www.discogs.com/artist/18837
https://play.spotify.com/artist/3RNrq3jvMZxD9ZyoOZbQOD

Zeremy thanks, i will test some of this..

For now there is script that scratch bio from web (last.fm and wikipedia).
It behaves same as Marc original script(right click change source) and use common8.js
You can also change folder path for saved text..
Why i make this is because echonest( Marc use) update text only after one week or one month, as i see on some edited bio.
Wikipedia bio still has some problems(i don't use (musician),(band),(entertainer),(singer) there) , but it works on 90% artists.
Maybe i will add  (last.fm) album info later..

If someone need to see updated text instantly, that's it..

Script is also easy to modify if someone wants to add new sources..
I was needed something that i can later modify if conditions on site was changed, so now i can do this easy(or change source site), i don't depend on others anymore..

So here is script:

Code: [Select]
// ==PREPROCESSOR==
// @name "Biography Text"
// @author "Mire777"
// @import "%fb2k_profile_path%marc2003\common8.js"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

//BEGIN-->
var p = new panel("Last.fm", ["metadb", "remap"]);
var t = new text("custom", 6, 30, p.w - 12, p.h - 30);

//properties..
source = window.GetProperty("2k3.download_source", "last.fm");
var fbfolder = (fb.ProfilePath + "Artist_info");
var folder = window.GetProperty("2k3.custom_folder", fbfolder);

//metadb/playback
on_metadb_changed();
on_playback_new_track();

//Folder call
var fso = new ActiveXObject("Scripting.FileSystemObject");
WshShell = new ActiveXObject("WScript.Shell");

//on size
function on_size() {
p.size();
t.w = p.w - 12;
t.h = p.h - 30;
t.size();
}

//on paint
function on_paint(gr) {
    if (t.text > "") {
p.draw_background(gr);
p.left_text(gr, p.artist, p.title_font, p.textcolour_hl, 6, 6, p.w - 12, 24);
gr.DrawLine(6, 29, p.w - 6, 29, 1, p.textcolour_hl);
t.draw(gr);
}}

//metadb changed
function on_metadb_changed() {
if (!p.metadb) return;
p.artist = p.eval(p.artist_tf);
if (t.artist == p.artist) return;
t.artist = p.artist;
t.text = "";
if (folder>"")
{
//Create main folder 'Artist_info'
if(!fso.FolderExists(folder)) fso.CreateFolder(folder);
   
//Create subfolder 'artist'
if(!fso.FolderExists(folder + "\\"+(p.artist.validate()))) fso.CreateFolder(folder + "\\"+(p.artist.validate()));
}

//folder + 'bio.txt'
t.filename = folder + "\\"+(p.artist.validate()) + "\\bio.txt";
   
//Check if folder exist then >continue..
if (t.filename.is_file()) {
t.text = p.open(t.filename);
if (t.filename.expired(ONE_DAY) && source=="last.fm") {get();}
else
if (t.filename.expired(ONE_DAY) && source=="wikipedia") {get2();}
} else {
if (source=="last.fm") {get();}
else
if (source=="wikipedia") {get2();}
}
t.update();
window.Repaint();
}

//wheel step
function on_mouse_wheel(step) {
t.wheel(step);
}

//on mouse move
function on_mouse_move(x, y) {
p.move(x, y);
t.move(x, y);
}

//on mouse lbtn_up
function on_mouse_lbtn_up(x, y) {
t.lbtn_up(x, y);
}

//1st bio text
function get() {
if (t.artist == "" || t.artist == "?") return;
var fn = t.filename;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(t.artist) + "/+wiki", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < 1; i++) {
if (data[i].id.indexOf("about:/wiki/") == 0);

//find text from tag%tag
var st = text.indexOf( data[i].id.replace("about:/wiki/", ""));
var str = "id=\"wiki\">";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</div>", st);
var artt = text.substr(st, et - st);
t.text = artt;

//check if biography exist
if (t.text.indexOf("TYPE")==0) {t.text = "This artist does not have a biography";}

else

//clean text(marc)
t.text = p.strip_tags(t.text);

//clean other
{t.text = t.text.replace(/\n\r/g, "\n").replace(/\n\n/g, "\n").trim();}

//if clean not work use this:
//.replace(/<\/?[^>]+(>|$)/g, "").replace(/\n/g, "<br>").replace(/<BR>/g,"\n").replace(/&amp;/g,"&").replace(/<br>/g,"---").replace(/---/g,"\n\r");
//console
//fb.trace("bio: " + t.text);
{
p.save(t.text, fn);
t.update();
window.Repaint();
};
}

this.doc.close();

} else {
fb.trace("HTTP error: " + this.xmlhttp.status);
{t.text = "This artist does not have a biography";}
p.save(t.text, fn);
t.update();
window.Repaint();
}}}}

//2nd bio text
function get2() {
if (t.artist == "" || t.artist == "?") return;
var fn = t.filename;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://en.wikipedia.org/wiki/" + encodeURIComponent(t.artist) + "", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < 1; i++) {
if (data[i].id.indexOf("about:/wiki/") == 0);

//find text from tag%tag
var st = text.indexOf( data[i].id.replace("about:/wiki/", ""));
var str = "<p>";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</html>", st);
var artt = text.substr(st, et - st);
t.text = artt;

//check if biography exist
if (t.text.indexOf("TYPE")==0) {t.text = "This artist does not have a biography";}
if (t.text.indexOf("may refer to")>0) {t.text = "This artist does not have a biography";}
if (t.text.indexOf("can refer to")>0) {t.text = "This artist does not have a biography";}
else

//clean text(marc)
t.text = p.strip_tags(t.text);

//clean other
{t.text = t.text.replace(/\n\r/g, "\n").replace(/\n/g, "\n\n").replace(/[?[0-9]+?]/g, "").replace(/\[?edit+?]/g, "").replace(/\n+Contents?[^>]+?External links/g, "").replace(/\n+Contents?[^>]+?References/g, "").replace(/[0-9] Filmography/, "").replace(/[0-9] Discography/, "").replace(/[0-9] References/, "").replace(/[0-9] Notes/, "").split("Filmography")[0].split("Discography")[0].split("References")[0].replace(/\n\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").replace(/[?[citatio]+?n n/g, "").replace(/Sorry, your browser either has JavaScript disabled or does not have any supported player./g, "").replace(/You can download the clip or download a player to play the clip in your browser./g, "").replace(/Problems playing this file[?]/g, "").replace(/See media help./g, "").replace(/\n\r/g, "\n").replace(/\n\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").trim();}

//if clean not work use this:
//.replace(/<\/?[^>]+(>|$)/g, "").replace(/\n/g, "<br>").replace(/<BR>/g,"\n").replace(/&amp;/g,"&").replace(/<br>/g,"---").replace(/---/g,"\n\r");
//console
//fb.trace("bio: " + t.text);
{
p.save(t.text, fn);
t.update();
window.Repaint();
};
}

this.doc.close();

} else {
fb.trace("HTTP error: " + this.xmlhttp.status);
{t.text = "This artist does not have a biography";}
p.save(t.text, fn);
t.update();
window.Repaint();
}}}}

//menu
function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Last.fm");
_menu.AppendMenuItem(MF_STRING, 3, "Wikipedia");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Open Folder");
if (source=="last.fm") _menu.AppendMenuItem(MF_STRING, 5, "Open Last.fm");
if (source=="wikipedia") _menu.AppendMenuItem(MF_STRING, 5, "Open Wiki.");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 6, "Properties");

if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 7, "Configure...");

_menu.CheckMenuRadioItem(2, 3, source == "last.fm" ? 2 : 3);

idx = _menu.TrackPopupMenu(x, y);
if(idx == 1) if (p.metadb) {if (source=="last.fm") {get();} else if (source=="wikipedia") {get2();}}
if(idx == 2) if (p.metadb) {source = idx == 2 ? "last.fm" : "wikipedia"; window.SetProperty("2k3.download_source", source); get();}
if(idx == 3) if (p.metadb) {source = idx == 3 ? "wikipedia" : "last.fm"; window.SetProperty("2k3.download_source", source); get2();}
if(idx == 4) p.run("explorer /select,\"" +  t.filename);
if(idx == 5) if (p.metadb) {if (source=="last.fm") {p.browser("http://www.last.fm/music/" + encodeURIComponent(t.artist));} else if (source=="wikipedia") {p.browser("http://en.wikipedia.org/wiki/" + encodeURIComponent(t.artist));}}
if(idx == 6) window.ShowProperties();
if(idx == 7) window.ShowConfigure();
_menu.Dispose();
return true;
}



WSH Panel Mod script discussion/help

Reply #3429
So here is script:


the way it does a new web request every time you change the source from the menu isn't great. instead, you should store 2 files in your artist folder - one for last.fm and one for wikipedia. your filename should be generated depending on what the source is. then when you have text from each source, you can switch between them instantly without contacting the web.

i'll post some more stuff later that should help you out - i don't have time at the moment.

edit: i will just post this about creating custom menus...

make sure you have the latest common8.js in your marc2003 folder: https://dl.dropboxusercontent.com/u/2280132...2003/common8.js

on your first line of code, modify it like this...

Code: [Select]
var p = new panel("Last.fm", ["metadb", "remap", "custom_menu"]);


put this as the last line of code in your on_paint function....

Code: [Select]
p.menu_btn.draw(gr);


put this as the first line of code in the on_mouse_rbtn_up function..

Code: [Select]
if (p.menu_btn.lbtn_up(x, y)) return;


then at the end of the script, you can define your own custom menu with...

Code: [Select]
p.menu = function() {
    var _menu = window.CreatePopupMenu();
    //create menu items
    var idx = _menu.TrackPopupMenu(p.menu_btn.x, p.menu_btn.y);
    //process response
    _menu.Dispose();
}


the icon for the menu only appears in the top left when your mouse hovers over the panel. the reason for doing this is so you still get all the right click options like font size, selection mode, artist field remapping that are provided by my script.


WSH Panel Mod script discussion/help

Reply #3430
So here is script:


the way it does a new web request every time you change the source from the menu isn't great. instead, you should store 2 files in your artist folder - one for last.fm and one for wikipedia. your filename should be generated depending on what the source is. then when you have text from each source, you can switch between them instantly without contacting the web.

i'll post some more stuff later that should help you out - i don't have time at the moment.


Yes, you're right having 2 files instead one would be better. I'll do this later.
Would be good to know how to modify Thumbs script for new sources..
I already do this, but this script don't use common8.js
Good thing is you always give support and update your samples often.
Thanks for your guide, realy helps..

WSH Panel Mod script discussion/help

Reply #3431
see my edit above and yes i can provide help for getting my thumbs script to use a different source. i'll try and get on it later.

WSH Panel Mod script discussion/help

Reply #3432
see my edit above and yes i can provide help for getting my thumbs script to use a different source. i'll try and get on it later.


Nice idea, then i can easy update script with right click menu.
But, problem is that i have icon on top left corner while this works, your menu doesn't appear.
I have only properties and configure..

WSH Panel Mod script discussion/help

Reply #3433
i just realised there's a stupid typo in my post above, it should on_mouse_lbtn_up. make sure you have no on_mouse_rbtn_up in the panel at all and then my right click menu will work.

WSH Panel Mod script discussion/help

Reply #3434
i just realised there's a stupid typo in my post above, it should on_mouse_lbtn_up. make sure you have no on_mouse_rbtn_up in the panel at all and then my right click menu will work.

Yes it works

If someone already use this, here is new script, with all the right click options provided by Marc script:

Code: [Select]
// ==PREPROCESSOR==
// @name "Biography Text"
// @author "Mire777"
// @import "%fb2k_profile_path%marc2003\common8.js"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

//BEGIN-->
var p = new panel("Last.fm", ["metadb", "remap","custom_menu"]);
var t = new text("custom", 6, 30, p.w - 12, p.h - 30);

//properties..
source = window.GetProperty("2k3.download_source", "last.fm");
var fbfolder = (fb.ProfilePath + "Artist_info");
var folder = window.GetProperty("2k3.custom_folder", fbfolder);

//metadb/playback
on_metadb_changed();
on_playback_new_track();

//Folder call
var fso = new ActiveXObject("Scripting.FileSystemObject");
WshShell = new ActiveXObject("WScript.Shell");

//on size
function on_size() {
p.size();
t.w = p.w - 12;
t.h = p.h - 30;
t.size();
}

//on paint
function on_paint(gr) {
if (t.text > "") {
p.draw_background(gr);
p.left_text(gr, p.artist, p.title_font, p.textcolour_hl, 6, 6, p.w - 12, 24);
gr.DrawLine(6, 29, p.w - 6, 29, 1, p.textcolour_hl);
t.draw(gr);
p.menu_btn.draw(gr);
}}

//metadb changed
function on_metadb_changed() {
if (!p.metadb) return;
p.artist = p.eval(p.artist_tf);
if (t.artist == p.artist) return;
t.artist = p.artist;
t.text = "";
if (folder>"")
{
//Create main folder 'Artist_info'
if(!fso.FolderExists(folder)) fso.CreateFolder(folder);
   
//Create subfolder 'artist'
if(!fso.FolderExists(folder + "\\"+(p.artist.validate()))) fso.CreateFolder(folder + "\\"+(p.artist.validate()));
}

//folder + 'bio.txt'
t.filename = folder + "\\"+(p.artist.validate()) + "\\bio.txt";
   
//Check if folder exist then >continue..
if (t.filename.is_file()) {
t.text = p.open(t.filename);
if (t.filename.expired(ONE_DAY) && source=="last.fm") {get();}
else
if (t.filename.expired(ONE_DAY) && source=="wikipedia") {get2();}
} else {
if (source=="last.fm") {get();}
else
if (source=="wikipedia") {get2();}
}
t.update();
window.Repaint();
}

//wheel step
function on_mouse_wheel(step) {
t.wheel(step);
}

//on mouse move
function on_mouse_move(x, y) {
p.move(x, y);
t.move(x, y);
}

//on mouse lbtn_up
function on_mouse_lbtn_up(x, y) {
if (p.menu_btn.lbtn_up(x, y)) return;
}

//1st bio text
function get() {
if (t.artist == "" || t.artist == "?") return;
var fn = t.filename;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(t.artist) + "/+wiki", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < 1; i++) {
if (data[i].id.indexOf("about:/wiki/") == 0);

//find text from tag%tag
var st = text.indexOf( data[i].id.replace("about:/wiki/", ""));
var str = "id=\"wiki\">";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</div>", st);
var artt = text.substr(st, et - st);
t.text = artt;

//check if biography exist
if (t.text.indexOf("TYPE")==0) {t.text = "This artist does not have a biography";}

else

//clean text(marc)
t.text = p.strip_tags(t.text);

//clean other
{t.text = t.text.replace(/\n\r/g, "\n").replace(/\n\n/g, "\n").trim();}

//if clean not work use this:
//.replace(/<\/?[^>]+(>|$)/g, "").replace(/\n/g, "<br>").replace(/<BR>/g,"\n").replace(/&amp;/g,"&").replace(/<br>/g,"---").replace(/---/g,"\n\r");
//console
//fb.trace("bio: " + t.text);
{
p.save(t.text, fn);
t.update();
window.Repaint();
};
}

this.doc.close();

} else {
fb.trace("HTTP error: " + this.xmlhttp.status);
{t.text = "This artist does not have a biography";}
p.save(t.text, fn);
t.update();
window.Repaint();
}}}}

//2nd bio text
function get2() {
if (t.artist == "" || t.artist == "?") return;
var fn = t.filename;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://en.wikipedia.org/wiki/" + encodeURIComponent(t.artist) + "", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < 1; i++) {
if (data[i].id.indexOf("about:/wiki/") == 0);

//find text from tag%tag
var st = text.indexOf( data[i].id.replace("about:/wiki/", ""));
var str = "<p>";
st = text.indexOf(str, st) + str.length;
var et = text.indexOf("</html>", st);
var artt = text.substr(st, et - st);
t.text = artt;

//check if biography exist
if (t.text.indexOf("TYPE")==0) {t.text = "This artist does not have a biography";}
if (t.text.indexOf("may refer to")>0) {t.text = "This artist does not have a biography";}
if (t.text.indexOf("can refer to")>0) {t.text = "This artist does not have a biography";}
else

//clean text(marc)
t.text = p.strip_tags(t.text);

//clean other
{t.text = t.text.replace(/\n\r/g, "\n").replace(/\n/g, "\n\n").replace(/[?[0-9]+?]/g, "").replace(/\[?edit+?]/g, "").replace(/\n+Contents?[^>]+?External links/g, "").replace(/\n+Contents?[^>]+?References/g, "").replace(/[0-9] Filmography/, "").replace(/[0-9] Discography/, "").replace(/[0-9] References/, "").replace(/[0-9] Notes/, "").split("Filmography")[0].split("Discography")[0].split("References")[0].replace(/\n\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").replace(/[?[citatio]+?n n/g, "").replace(/Sorry, your browser either has JavaScript disabled or does not have any supported player./g, "").replace(/You can download the clip or download a player to play the clip in your browser./g, "").replace(/Problems playing this file[?]/g, "").replace(/See media help./g, "").replace(/\n\r/g, "\n").replace(/\n\n\n\n/g, "\n").replace(/\n\n\n/g, "\n").trim();}

//if clean not work use this:
//.replace(/<\/?[^>]+(>|$)/g, "").replace(/\n/g, "<br>").replace(/<BR>/g,"\n").replace(/&amp;/g,"&").replace(/<br>/g,"---").replace(/---/g,"\n\r");
//console
//fb.trace("bio: " + t.text);
{
p.save(t.text, fn);
t.update();
window.Repaint();
};
}

this.doc.close();

} else {
fb.trace("HTTP error: " + this.xmlhttp.status);
{t.text = "This artist does not have a biography";}
p.save(t.text, fn);
t.update();
window.Repaint();
}}}}

//menu
p.menu = function() {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Last.fm");
_menu.AppendMenuItem(MF_STRING, 3, "Wikipedia");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Open Folder");
if (source=="last.fm") _menu.AppendMenuItem(MF_STRING, 5, "Open Last.fm");
if (source=="wikipedia") _menu.AppendMenuItem(MF_STRING, 5, "Open Wiki.");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 6, "Properties");

if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 7, "Configure...");

_menu.CheckMenuRadioItem(2, 3, source == "last.fm" ? 2 : 3);

var idx = _menu.TrackPopupMenu(p.menu_btn.x, p.menu_btn.y);

if(idx == 1) if (p.metadb) {if (source=="last.fm") {get();} else if (source=="wikipedia") {get2();}}
if(idx == 2) if (p.metadb) {source = idx == 2 ? "last.fm" : "wikipedia"; window.SetProperty("2k3.download_source", source); get();}
if(idx == 3) if (p.metadb) {source = idx == 3 ? "wikipedia" : "last.fm"; window.SetProperty("2k3.download_source", source); get2();}
if(idx == 4) p.run("explorer /select,\"" +  t.filename);
if(idx == 5) if (p.metadb) {if (source=="last.fm") {p.browser("http://www.last.fm/music/" + encodeURIComponent(t.artist));} else if (source=="wikipedia") {p.browser("http://en.wikipedia.org/wiki/" + encodeURIComponent(t.artist));}}
if(idx == 6) window.ShowProperties();
if(idx == 7) window.ShowConfigure();
_menu.Dispose();
return true;
}

WSH Panel Mod script discussion/help

Reply #3435
Marc, can i move this button on right, on right would be better, because there's no text..

WSH Panel Mod script discussion/help

Reply #3436
sure. just add this as the last line inside the on_size function.

Code: [Select]
p.menu_btn.x = p.w - p.menu_btn.w;

 

WSH Panel Mod script discussion/help

Reply #3438
finally, i've uploaded a full customisation page. it's bound to be full of typos and errors.

http://marc2003.x10host.com/customisation

it doesn't cover topics like fetching stuff off the internet yet. i'll get round to it oneday. 


Really nice, thanks.

"Fetching stuff off the internet", you mean like wiki/last.fm biographies? Is it hard to change those websites and use some others for infos? I have some "weird" ones in mind to use, like imdb, rottentomatoes, goodreads,... (for some other configurations of course, not for general music - last.fm is still the top there).

Great work!

WSH Panel Mod script discussion/help

Reply #3439
yes you could use any source you like. that's the plan anyway. the big problem is that i despise writing guides/documentation. it really sucks the life out of me which is why i'm always putting it off.

WSH Panel Mod script discussion/help

Reply #3440
sure. just add this as the last line inside the on_size function.

Code: [Select]
p.menu_btn.x = p.w - p.menu_btn.w;



Great, thanks


@mire777

You need to add  a line for the text up/down scrolling buttons

//on mouse lbtn_up
function on_mouse_lbtn_up(x, y) {
if (p.menu_btn.lbtn_up(x, y)) return;
t.lbtn_up(x, y);
}

WSH Panel Mod script discussion/help

Reply #3441
I discovered the interesting script marc2003!
In the beginning, did not work, then I corrected:
line 1525:
help: gdi.Image(p.ip + "buttons\\help.png"),
in
help: gdi.Image(p.ip + "buttons\\help.png")
and it work nice.
I read
I read somewhere else that it was possible to change the language of the biography, also only for wikipedia.  We can no longer?
you can download the bio only when the panel is visible, to avoid continuous unwanted downloads?

WSH Panel Mod script discussion/help

Reply #3442
that comma shouldn't be there but it still worked fine for me??? anyway, i've updated the script to remove it.

as for language support, lots of things have changed since that very old post and my scripts only fetch results in english now.

WSH Panel Mod script discussion/help

Reply #3443
you can download the bio only when the panel is visible, to avoid continuous unwanted downloads?

WSH Panel Mod script discussion/help

Reply #3444
sorry but i'm not making that change.

WSH Panel Mod script discussion/help

Reply #3445
I read somewhere else that it was possible to change the language of the biography, also only for wikipedia.  We can no longer?

This is why i made this script, you can change language for wikipedia and last.fm.
Top Right corner>properties>domen1 and domen2.
There you should enter example: for bio in germany: (domen1: lastfm.de ; domen2: de.wikipedia)


WSH Panel Mod script discussion/help

Reply #3446
@mire777, the chances of me writing more docs soon is unlikely so i've hacked your script a bit to tidy up. i even corrected some of my own mistakes - be sure to check all the comments.

https://dl.dropboxusercontent.com/u/2280132...emp/mire777.txt

i'll post a modified thumbs script for you to use with your own source soon as well.

WSH Panel Mod script discussion/help

Reply #3447
@mire777, the chances of me writing more docs soon is unlikely so i've hacked your script a bit to tidy up. i even corrected some of my own mistakes - be sure to check all the comments.

https://dl.dropboxusercontent.com/u/2280132...emp/mire777.txt

i'll post a modified thumbs script for you to use with your own source soon as well.


Yes, i see where is some problems. You corrected this..
I will wait for modified Thumbs script, i have old mod. script, and it's in totaly mess

WSH Panel Mod script discussion/help

Reply #3448
can you post your equivalent get function from your mod. i need to have a look at what url you're fetching and how you're parsing the response.

WSH Panel Mod script discussion/help

Reply #3449
can you post your equivalent get function from your mod. i need to have a look at what url you're fetching and how you're parsing the response.

Yes, here is code.
But as you already know. I didnt care to download full size images from yahoo and google.
Script download only small images.
You should look in html and find where is link for full size images..


Code: [Select]
//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);
//download one img and then return
if (im.images.length == 0) {im.update(); fix_limit = im.limit+1;}
//if img not downloaded return..
                    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=="yahoo")
    {{
        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://images.search.yahoo.com/search/images?p=" + encodeURIComponent(p.artist) + "+" + terms, 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("li");
div.innerHTML = text;
var data = div.getElementsByTagName("img");
var urls = [];

if (im.images.length < im.limit)
                      {
                    for (v = 0; v < data.length; v++) {
if (data[v].src.indexOf("http://ts") == 0) urls.push(data[v].src.replace("", ""));
}
                    fix_limit = im.limit;
for (v = 0; v < Math.min(urls.length, fix_limit, 50); v++) {
p.WshShell.Run("cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + urls[v] + "\" \"" + [folder + p.clean_filename(p.artist) + "_" + v] + urls[v].substring(urls[v].lastIndexOf("ts")+1000) + ".jpg" + "\"" , 0, true);
                    if (im.images.length == 0) {im.update(); fix_limit = im.limit;}
                    if (im.images.length == 0) {return;}
                    }
               
                    if (im.images.length < im.limit)
                    {
                    for (i = 0; i < data.length; i++) {
if (data[i].src.indexOf("http://d") == 0) urls.push(data[i].src.replace("", ""));
}
                    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("d")+1000) + ".jpg" + "\"" , 0, true);
                    if (im.images.length == 0) {im.update(); fix_limit = im.limit;}
                    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 + urls);
                  }
               
}}}}}
else

if (server=="google")
    {{
        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", "https://www.google.com/search?q=" + encodeURIComponent(p.artist) + "+" + terms + "&sei=GAKAUuvmD-WC4gTL9IC4AQ&gbv=2&tbm=isch", 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("https://encrypted") == 0) urls.push(data[i].src.replace("", ""));
}
                    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("d")+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 + urls);
}}}}}}}