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 1401105 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #4275
@zeremy, i was merely "observing" that you guys always manage to take working code and break it.  but if it works...

@mire777, you could tidy that up a lot...

Code: [Select]
try {
    var json_data = JSON.parse(xmlhttp.ResponseText);
    var artists = json_data.similarartists.artist;
    if (artists.length == 0) {
        SIM_ART = "";
    } else {
        SIM_ART = artists[Math.floor(Math.random() * artists.length)].name;
    }
    window.SetProperty("Similar", SIM_ART);
} catch (e) {
}

WSH Panel Mod script discussion/help

Reply #4276
@zeremy, i was merely "observing" that you guys always manage to take working code and break it.  but if it works...

@mire777, you could tidy that up a lot...

Code: [Select]
try {
    var json_data = JSON.parse(xmlhttp.ResponseText);
    var artists = json_data.similarartists.artist;
    if (artists.length == 0) {
        SIM_ART = "";
    } else {
        SIM_ART = artists[Math.floor(Math.random() * artists.length)].name;
    }
    window.SetProperty("Similar", SIM_ART);
} catch (e) {
}


Probably something is broken
Thank you

WSH Panel Mod script discussion/help

Reply #4277
I was trying to create a shuffle button and I managed to do it somehow, but now I also wanted it to be able to change Replay Gain from album to track when shuffling but I couldn't find a command for this, so is there some command for it?

And secondly is there a way to find out what are the fb. commands for all the different actions that foobar does?

WSH Panel Mod script discussion/help

Reply #4278
I was trying to create a shuffle button and I managed to do it somehow, but now I also wanted it to be able to change Replay Gain from album to track when shuffling but I couldn't find a command for this, so is there some command for it?

Foobar does it itself: Preferences-Playback-Replaygain-by playback order

WSH Panel Mod script discussion/help

Reply #4279
Thanks, that made my life a bit simpler.

WSH Panel Mod script discussion/help

Reply #4280
Updated ''Youtube Radio'' script, if someone still use this, previous script is stop working, i now use last.fm API.
You must enter your Api in properties. Link for download>

WSH Panel Mod script discussion/help

Reply #4281
it's worth mentioning that you cannot signup for a new API key at the moment. even if you already have one, the API section of the site will not let you log in. the only way to view API account details is if you signed in before the site switchover and you have some old cookies lurking about that are keeping you logged in.


WSH Panel Mod script discussion/help

Reply #4283
Hi . Prompt how to solve the problem. As long as I found two ways to refresh (PSS to control through WSH) :
1. :
Code: [Select]
function RefreshPSS() {
 if (fb.IsPlaying || fb.IsPaused) {
 fb.RunMainMenuCommand("Playback/Play or Pause");
 fb.RunMainMenuCommand("Playback/Play or Pause");
 }
 else {
 fb.RunMainMenuCommand("Playback/Play");
 fb.RunMainMenuCommand("Playback/Stop");
 }
 }
2.
Code: [Select]
   if (fb.IsPlaying || fb.IsPaused) {   
        fb.RunMainMenuCommand("View/Show status bar");
        fb.RunMainMenuCommand("View/Show status bar");
    } else {
        fb.RunMainMenuCommand("View/Show status bar");
        fb.RunMainMenuCommand("View/Show status bar");
    }
First - creates sound skips when using Asio driver, second - jump up and blink panel. What still has a way to refresh? The entire script (Refresh changes through Properties):

Code: [Select]
//==============Button timer
//==============================================================
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",11,1);
var font2 = gdi.Font("Guifx v2 Transports",40,0);
var ww,wh;
var on_mouse = false;
var Refresh_sys = window.GetProperty("Refresh_sys",true)
var seconds = window.GetProperty("seconds",5000)

function StringFormat() {
var h_align = 0,
v_align = 0,
trimming = 0,
flags = 0;
switch (arguments.length) {
case 3:
trimming = arguments[2];
case 2:
v_align = arguments[1];
case 1:
h_align = arguments[0];
break;
default:
return 0;
};
return ((h_align << 28) | (v_align << 24) | (trimming << 20) | flags);
};

StringAlignment = {
Near: 0,
Centre: 1,
Far: 2
};
var lt_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Near);
var ct_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Near);
var rt_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Near);
var lc_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Centre);
var cc_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Centre);
var rc_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Centre);
var lb_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Far);
var cb_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Far);
var rb_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Far);

function on_size(){
ww = window.Width; 
wh = window.Height;
}

var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists( fb.ProfilePath + "settings")) {fso.CreateFolder( fb.ProfilePath + "settings" )};
var set_path = fb.ProfilePath + "\\settings\\";

var img_path = fb.ProfilePath + "\\themes\\";

var n_btn = gdi.Image(img_path + "n.png");
var h_btn = gdi.Image(img_path + "h.png");
//var on_btn  = gdi.Image(img_path + "toolbar_1.png");
//var off_btn = gdi.Image(img_path + "toolbar_0.png");
var on_btn  = "s";
var off_btn = "w";
var is_toolbar = 0;
if(fso.FileExists( set_path + "toolbar_1")) {
fso.deleteFile( set_path + "toolbar_" + "*" );
fso.CreateTextFile( set_path + "toolbar_0" )
RefreshPSS();
}
function on_paint(gr){
//gr.FillSolidRect (0, 0, ww, wh, RGB(47,48,53));
gr.SetTextRenderingHint(4);
//gr.DrawString(is_toolbar == 0 ? off_btn : on_btn,font2,RGB(220,20,60),0,0,ww,wh,cc_stringformat);
gr.SetTextRenderingHint(0);
gr.DrawImage( on_mouse? h_btn : n_btn, 0, 0, 80, 80, 0, 0, 80, 80, 0, 255);
//gr.DrawImage( is_toolbar == 0 ? off_btn : on_btn, 0, 0, 80, 80, 0, 0, 80, 80, 0, 255);
}

function on_mouse_lbtn_up (x, y){
is_toolbar = is_toolbar == 1 ? 0 : 1;
try { fso.deleteFile( set_path + "toolbar_" + "*" )
} catch(e) {};
fso.CreateTextFile( set_path + "toolbar_" + is_toolbar );

RefreshPSS();

if (is_toolbar == 0) { if (g_timer){window.ClearTimeout(g_timer)}; return};
ch_state_btb();
}

var g_timer;

function ch_state_btb(){
g_timer = window.SetTimeout(function() {
if(fso.FileExists( set_path + "toolbar_1")) {
fso.deleteFile( set_path + "toolbar_" + "*" );
fso.CreateTextFile( set_path + "toolbar_0" )
is_toolbar = 0;
window.Repaint();
RefreshPSS();
window.ClearTimeout(g_timer);

}, seconds);
}

function RefreshPSS() {
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

function on_mouse_move(x, y) {
on_mouse = true;
window.Repaint();


function on_mouse_leave() { 
on_mouse = false;
window.Repaint();
}



WSH Panel Mod script discussion/help

Reply #4284
First - creates sound skips when using Asio driver


use directsound... or don't use dirty hacks which cause these undesirable side effects. the choice is yours.


WSH Panel Mod script discussion/help

Reply #4286
I've been using Marc2003's "Now Playing" panel for a number of years, but it appears to have stopped working due to the new last.fm.

Anyone know what changes might need to be made to the script to make it operational again?

Code for reference:

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common7.js"
// @name "Now Playing"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

//the track info section displays 3 lines of title formatted text. you can customise that here/////////////////////////////////////////////
var line1 = {
text: "", //leave this blank
tf: "%artist%", //enter any title formatting
font: gdi.Font("Segoe UI", 30, 1), //font name, size, style. 1 means bold and 0 is normal.
colour: RGB(40,179,255), //colour
y: 0 //change this value to move text up or down.
}
var line2 = {
text: "",
tf: "[%discnumber%.]%tracknumber%'/'[%discnumber%.]%totaltracks% - %title%",
font: gdi.Font("Segoe UI", 23, 1),
colour: RGB(210, 210, 210),
y: 38
}
var line3 = {
text: "",
tf: "$ifequal([%LASTFM_LOVED_DB%],1,♥,)",
font: gdi.Font("Segoe UI", 23, 1),
colour: RGB(255,0,0),
y: 70
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var p = new panel("Now Playing", ["custom_background", "now_playing", "lastfm_wiki", "remap"]);
p.version = "7.2013-04-23.01";
p.filename = "now playing.txt";
var c = new cd(0, 0, 0, 0);
var r = new rating(0, 0, 24);
var t = new text(0, 0, 0, 0);
var im = new images(0, 0, 0, 0);
var th = new thumbs(0, 0 , 0, 0)
var b = new buttons();
p.check_version();

p.selection_mode = 1;

var np_cd = window.GetProperty("np_cd", true);
var np_cd_size = window.GetProperty("np_cd_size", 200);
var np_track = window.GetProperty("np_track", true);
var np_track_top = window.GetProperty("np_track_top", false);
var np_buttons = window.GetProperty("np_buttons", true);
var np_bio = window.GetProperty("np_bio", true);
var np_cd_size = window.GetProperty("np_cd_size", 200);
var np_rating = window.GetProperty("np_rating", true);

var bar1y = 0;
var bar1h = 0;
var bar2y = 0;
var bar2h = 0;

b.update = function() {
if (p.metadb) {
var artist = encodeURIComponent(p.eval("%artist%"));
var title = encodeURIComponent(p.eval("%title%"));
var google = "https://www.google.co.uk/search?q=" + artist;
var myspace = "http://www.myspace.com/search/music?q=" + artist;
var lastfm = "http://www.last.fm/music/" + artist + "/_/" + title;
var youtube = "http://www.youtube.com/results?search_query=" + artist + "+" + title;
var discogs = "http://www.discogs.com/search?q=" + artist;
var allmusic = "http://www.allmusic.com/search/artists/" + artist;
b.buttons = {
google: new button(im.x + im.w - 192, bar2y - 1, 32, 32, {normal: "google.png", hover: "google_h.png"}, function() { p.browser(google); }, google),
myspace: new button(im.x + im.w - 160, bar2y - 1, 32, 32, {normal: "myspace.png", hover: "myspace_h.png"}, function() { p.browser(myspace); }, myspace),
lastfm: new button(im.x + im.w - 128, bar2y - 1, 32, 32, {normal: "lastfm.png", hover: "lastfm_h.png"}, function() { p.browser(lastfm); }, lastfm),
youtube: new button(im.x + im.w - 96, bar2y - 1, 32, 32, {normal: "youtube.png", hover: "youtube_h.png"}, function() { p.browser(youtube); }, youtube),
discogs: new button(im.x + im.w - 64, bar2y - 1, 32, 32, {normal: "discogs.png", hover: "discogs_h.png"}, function() { p.browser(discogs); }, discogs),
allmusic: new button(im.x + im.w - 32, bar2y - 1, 32, 32, {normal: "allmusic.png", hover: "allmusic_h.png"}, function() { p.browser(allmusic); }, allmusic)
}
}
window.RepaintRect(0, bar2y, im.w, bar2h);
}

on_item_focus_change();

function on_playback_time(time) {
im.playback_time(time);
}

function on_size() {
p.size();
th.calc();
switch(true) {
case np_track_top:
c.y = im.y - (np_cd_size * 0.05);
bar1y = im.y;
bar1h = np_track ? 100 : 0;
bar2y = im.y + bar1h;
bar2h = np_buttons || np_rating ? 30 : 0;
t.y = im.y + bar1h + bar2h;
break;
default:
c.y = im.y + im.h - np_cd_size + (np_cd_size * 0.05);
bar1y = im.y + (np_rating || np_buttons ? im.h - 130 : im.h - 100);
bar1h = np_track ? 100 : 0;
bar2y = im.y + im.h - 30;
bar2h = np_buttons || np_rating ? 30 : 0;
t.y = im.y;
break;
}
c.x = im.x;
c.w = np_cd_size;
c.h = np_cd_size;
r.y = bar2y + 3;
t.x = im.x + im.w - Math.round(im.w / 3);
t.w = im.x + im.w - t.x - 15;
t.h = im.h - bar1h - bar2h;
t.size();
b.update();
}

function on_paint(gr) {
p.draw_background(gr);
th.draw(gr);
tix = im.x + (np_cd ? np_cd_size : 10);
r.x = tix;
if (np_track) {
gr.FillSolidRect(im.x, bar1y, im.w, bar1h, RGBA(0, 0, 0, 196));
p.left_text(gr, line1.text, line1.font, line1.colour, tix, bar1y + line1.y, im.x + im.w - tix - 10, line1.font.Height);
p.left_text(gr, line2.text, line2.font, line2.colour, tix, bar1y + line2.y, im.x + im.w - tix - 10, line2.font.Height);
p.left_text(gr, line3.text, line3.font, line3.colour, tix, bar1y + line3.y, im.x + im.w - tix - 10, line3.font.Height);
}
if (np_rating || np_buttons) gr.FillSolidRect(im.x, bar2y, im.w, bar2h, RGBA(0, 0, 0, 136));
if (np_cd) c.draw(gr);
if (np_rating) r.draw(gr);
if (np_buttons) b.draw(gr);
if (np_bio) {
gr.FillSolidRect(t.x - 15, t.y, t.w + 30, t.h, RGBA(0, 0, 0, 156));
t.draw(gr, RGB(240, 240, 240));
}
}

function on_metadb_changed() {
b.update();
r.metadb_changed();
im.metadb_changed();
t.metadb_changed();
c.metadb_changed();
if (p.metadb) {
line1.text = p.eval(line1.tf);
line2.text = p.eval(line2.tf);
line3.text = p.eval(line3.tf);
}
window.Repaint();
}

function on_playback_stop() {
on_item_focus_change();
b.update();
}

function on_playback_pause() {
b.update();
}

function on_playback_starting() {
b.update();
}

function on_get_album_art_done(metadb, art_id, im, ip) {
c.get_album_art_done(ip);
}

function on_mouse_wheel(step) {
if (np_cd && c.trace(p.mx, p.my)) {
np_cd_size += step * 25;
if (np_cd_size < 200) np_cd_size = 200;
if (np_cd_size > 400) np_cd_size = 400;
window.SetProperty("np_cd_size", np_cd_size);
c.y = Math.round(np_track_top ? im.y - (np_cd_size * 0.05) : im.y + im.h - np_cd_size + (np_cd_size * 0.05));
c.w = np_cd_size;
c.h = np_cd_size;
window.RepaintRect(im.x, np_track_top ? im.y : im.y + im.h - 450, im.w, 450);
return;
}
if (th.wheel(step)) return;
if (np_bio && t.wheel(step)) return;
im.wheel(step);
}

function on_mouse_move(x, y) {
p.move(x, y);
if (np_rating && r.move(x, y)) return;
if (np_bio && t.move(x, y)) return;
if (np_buttons && b.move(x,y)) return;
if (np_cd && c.move(x, y)) return;
if (th.move(x, y)) return;
}

function on_mouse_lbtn_up(x, y) {
if (np_buttons && b.lbtn_up(x, y)) return;
if (np_rating && r.lbtn_up(x, y)) return;
if (np_bio && t.lbtn_up(x, y)) return;
if (th.lbtn_up(x, y)) return;
}

function on_mouse_lbtn_dblclk(x, y) {
if (np_cd && c.lbtn_dblclk(x, y)) return;
if (th.lbtn_dblclk(x, y)) return;
}


WSH Panel Mod script discussion/help

Reply #4288
..

WSH Panel Mod script discussion/help

Reply #4289
Total noob here, I'm trying to modify a script. I want to display an image depending on the name of an artist.

Code: [Select]
gdi.Image("cover/ARTIST.png")


I figured I could create a variable which looks something like this:

Code: [Select]
var tf_artist = fb.TitleFormat("%album artist%");


Now, how can I use that variable in my gdi.Image function?

WSH Panel Mod script discussion/help

Reply #4290
Ok let me pose the following question: Anyone know of a good script or plugin for a "now playing" panel? (something like below)


WSH Panel Mod script discussion/help

Reply #4291
Hi, could someone please help out with a WSH panel mod script ... I am new to it and having trouble getting into it. I've also tried extracting code from other skins with no luck.

What I am trying to do:  a simple panel (basically like a status bar) that shows info for the current playlist you are in - "number of items  |  play time (hours/days/weeks/etc)  |  size on disk (MB/GB)".
Thats it. And have it be customizable ... background color, font color/style/size ...

Thanks

WSH Panel Mod script discussion/help

Reply #4292
i've updated my scripts. it might have a feature some people have been missing...

https://github.com/19379/wsh_marc2003/releases

@magnumforce2006, i'm not updating any now playing scripts.

@sh1ggy, you'd be better off using the artreader functions built into the component. then you can configure file>preferences>display>album art>artist.

then you can use

Code: [Select]
var metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (!metadb)
     return;
var img = utils.GetAlbumArtV2(metadb, 4); //4 is for artist, 0 is front cover, 1 back, 2 disc, 3 icon


@mystNZ, the link above contains an example status bar script which displays playlist totals. it should be easy enough to figure out how to customise it.

WSH Panel Mod script discussion/help

Reply #4293
@mystNZ, the link above contains an example status bar script which displays playlist totals. it should be easy enough to figure out how to customise it.

Thanks Marc, that worked great!

WSH Panel Mod script discussion/help

Reply #4294
marc2003, thank you for updates. Also what about LastFM API? Is it still broken? I can 'love' tracks via Playcount sync (they actually get love status on LastFM), but it doesn't receive any response from LastFM. So, there're no database updates and it's impossible to unlove tracks via the script.
Code: [Select]
Last.fm Playcount Sync: Automatically loving this track.... 
Last.fm Playcount Sync: Attempting to love "My Favourite Faded Fantasy" by "Damien Rice"
Last.fm Playcount Sync: Contacting Last.fm....

WSH Panel Mod script discussion/help

Reply #4295
the code to love/unlove tracks can be modified to workaround the current API problems. open your common8.js in a decent text editor like notepad++. use ctrl+f to open the search dialog and look for this.post there should only be one result. it should be easy to see what bit of code you need to overwrite with this...

Code: [Select]
            case "track.love":
            case "track.unlove":
                var func = function() {
                    if (l.xmlhttp.responsetext.indexOf("ok") > -1) {
                        p.console("Track " + (method == "track.love" ? "loved successfully." : "unloved successfully."));
                        fb.RunContextCommandWithMetadb("Customdb Love " + (method == "track.love" ? 1 : 0), metadb, 8);
                    } else {
                        p.console(l.xmlhttp.responsetext);
                    }
                }
                
                if (!ps.check_component || !metadb || this.username.length == 0 || this.sk.length != 32)
                    return;
                var artist = tf(p.artist_tf, metadb);
                var track = tf("%title%", metadb);
                if (artist == "" || artist == "?")
                    return;
                p.console("Attempting to " + (method == "track.love" ? "love \"" : "unlove \"") + track + "\" by \"" + artist + "\"");
                p.console("Contacting Last.fm....");
                this.api_sig = md5("api_key" + this.api_key + "artist" + artist + "method" + method + "sk" + this.sk + "track" + track + this.secret);
                this.data = "method=" + method + "&api_key=" + this.api_key + "&api_sig=" + this.api_sig + "&sk=" + this.sk + "&artist=" + encodeURIComponent(artist) + "&track=" + encodeURIComponent(track);
                break;


there is no workaround for the import playcount function being broken.

WSH Panel Mod script discussion/help

Reply #4296
I created a script thumbs + last.fm bio.txt, using ideas from the script album art + allmusic review.txt (wsh_marc2003-v8).
The script can be downloaded at https://cloud.mail.ru/public/BXYt/Nas2XyHBs

bio preview:


thumbs preview:

WSH Panel Mod script discussion/help

Reply #4297
marc2003, it works great! Thank you. Don't care about playcount anyway.

WSH Panel Mod script discussion/help

Reply #4298
Don't care about playcount anyway.

Waaat???

I curse last.fm every single day for messing up the API (and hence playcount sync) with the update!!!111oneeleven

 

WSH Panel Mod script discussion/help

Reply #4299
the background updates as you listen still work. it's only the bulk import that is broken.