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

WSH Panel Mod script discussion/help

Reply #250
@ marc2003

Code: [Select]
}

function on_metadb_changed() {
    if(!g_metadb) return;
    var myspace = fb.TitleFormat("http://www.myspace.com/$replace(%artist%, ,)").EvalWithMetadb(g_metadb);
    var lastfm = fb.TitleFormat("http://www.last.fm/music/$replace(%artist%, ,+,/,'%'252F)/_/$replace(%title%, ,+,/,'%'252F)").EvalWithMetadb(g_metadb);
    var youtube = fb.TitleFormat("http://www.youtube.com/results?search_query=$replace(%artist%+%title%, ,+,'(',,')',,/,+,&,and)").EvalWithMetadb(g_metadb);
    var google = fb.Titleformat ("http://www.google.com/search?q=$replace(%artist%+%album%, ,+)&ie=utf-8").EvalWithMetadb(g_metadb);  

   Buttons = {
        but1: new Button(left_margin,top_margin,bw,bh, {normal: images_path + "myspace.png", hover: images_path + "myspace_h.png"}, function(){WshShell.run(myspace);}, myspace),
        but2: new Button(left_margin + bw,top_margin,bw,bh, {normal: images_path + "lastfm.png", hover: images_path + "lastfm_h.png"}, function(){WshShell.run(lastfm);}, lastfm),
        but3: new Button(left_margin + (bw*2),top_margin,bw,bh, {normal: images_path + "youtube.png", hover: images_path + "youtube_h.png"}, function(){WshShell.run(youtube);}, youtube)
        but4: new Button(left_margin + (bw*3),top_margin,bw,bh, {normal: images_path + "google.png", hover: images_path + "google_32.png"}, function(){WshShell.run(google);},google)

    }


If I understand correctly:
The first part is for definition of the variables or rather search strings. In my case i added google.
The second part is for placing the buttons. (bw*3 goes 32 pixels to the right,) right?
The only thing I can think of is that my search string is wrong..... 
I've borrowed that string from run services...
I'm really trying to figure this out now, so any help and explanation is greatly appreciated...

WSH Panel Mod script discussion/help

Reply #251
you need to add a comma at the end of the line of code that begins with "but3".

WSH Panel Mod script discussion/help

Reply #252
 thank you very much.

WSH Panel Mod script discussion/help

Reply #253
Hi there,

I'm using Marc's code to retrieve the biographie of the current artist by last.fm.
Is there any chance to get this biographie in another language as the standard code does (English)?

I do not see any paramter for this within the script at all.



WSH Panel Mod script discussion/help

Reply #256
I must say I don't know a thing about scripting, though I managed to learn to decipher some portions. Still, I have a question: in marc2003's "Now Playing" panel is there any way to make it use artist pics stored in a folder on my hdd?

Here's the script:
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\marc2003\v2\common.js"
// ==/PREPROCESSOR==


var title_tf =  fb.TitleFormat("%title%");
var album_tf = fb.TitleFormat("$if2(%album%,)");
var artist_tf = fb.TitleFormat("%artist%");
var g_font_title = gdi.Font("Agency FB", 34, 0);
var g_font_album = gdi.Font("Agency FB", 20, 0);
var g_font_artist = gdi.Font("Agency FB", 24, 0);

var album_img = null;
var artist_img = null;

var cycle = window.GetProperty("cycle", 200) - 200;
var limit = window.GetProperty("limit", 305) - 300;
var album_img_size = window.GetProperty("album_img_size", 490) - 400;

if(fb.IsPlaying) on_playback_new_track();

function on_playback_time(time) {
if(cycle > 0 && arr.length > 1 && (time % cycle == 0)) on_mouse_wheel(1);
}

function on_playback_stop(reason) {
if(album_img) album_img.Dispose();
if(artist_img) artist_img.Dispose();
g_metadb = album_img = artist_img = null;
if(reason != 2) window.Repaint();
}

function  on_playback_new_track() {
g_metadb = fb.GetNowPlaying();
artist = artist_tf.EvalWithMetadb(g_metadb);
title = title_tf.EvalWithMetadb(g_metadb);
album = album_tf.EvalWithMetadb(g_metadb);
if(album_img) album_img.Dispose();
album_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
if(album_img) {
window.Repaint();
} else {
utils.GetAlbumArtAsync(window.ID, g_metadb, 0);
}
folder = data_folder + fb.TitleFormat("$crc32(%artist%)").EvalWithMetadb(g_metadb);
var jpg = utils.Glob(folder + "\\*.jpg").toArray();
var png = utils.Glob(folder + "\\*.png").toArray();
var gif = utils.Glob(folder + "\\*.gif").toArray();
arr = jpg.concat(png, gif);
index = Math.floor(Math.random()*arr.length)
load_image();
}

function on_mouse_wheel(delta) {
if(arr.length < 2) return;
index += delta;
if(index < 0) index = arr.length-1;
if(index == arr.length) index = 0;
load_image();
}

function load_image() {
if(artist_img) artist_img.Dispose();
artist_image_path = arr[index];
artist_img = gdi.Image(artist_image_path);
window.Repaint();
}

function on_mouse_lbtn_dblclk() {
try {WshShell.Run("\"" + artist_image_path + "\""); } catch(e) {}
}

function on_get_album_art_done(metadb, art_id, im, ip) {
album_img = im;
window.Repaint();
}

function on_size() {
ww = window.width;
wh = window.height;
}

function scale(gr, img, pos_x, pos_y, width, height, mth) {
var s = mth == "max" ? Math.max(width / img.width, height / img.height) : Math.min(width / img.width, height / img.height);
var nw = img.width * s;
var nh = img.height * s;
pos_x += ((width - nw) / 2);
pos_y += ((height - nh) / 2);
gr.DrawImage(img, pos_x, pos_y, nw, nh, 0, 0, img.width, img.height);
}

function on_paint(gr) {
if(artist_img) {
gr.FillSolidRect( 0, 0,ww, wh, RGBA(0,0,0,200));
scale(gr, artist_img, 0, 0, ww, wh, "min")
} else {
gr.FillSolidRect( 0, 0,ww, wh, RGB(240,240,240));
}
gr.FillSolidRect(20,wh-130,ww - 40,110,RGBA(90,90,90,175));
if(album_img) {
text_x = album_img_size + 25;
scale(gr, album_img, 10, wh-10-album_img_size, album_img_size, album_img_size, "min");
} else {
text_x = 30;
}
if(fb.IsPlaying) {
gr.GdiDrawText(title, g_font_title, RGB(255,255,255), text_x, wh-130, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(album, g_font_album, RGB(255,255,255), text_x, wh-80, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(artist, g_font_artist, RGB(255,255,255), text_x, wh-55, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
}
}


function on_mouse_rbtn_up(x, y) {
var _menu = window.CreatePopupMenu();
var _cycle = window.CreatePopupMenu();
var _limit = window.CreatePopupMenu();
var _album = window.CreatePopupMenu();
var idx;
_cycle.AppendMenuItem(MF_STRING, 200, "Off");
_cycle.AppendMenuItem(MF_STRING, 205, "5 seconds");
_cycle.AppendMenuItem(MF_STRING, 210, "10 seconds");
_cycle.AppendMenuItem(MF_STRING, 220, "20 seconds");
_cycle.CheckMenuRadioItem(200, 220, window.GetProperty("cycle"));
_limit.AppendMenuItem(MF_STRING, 301, "1");
_limit.AppendMenuItem(MF_STRING, 303, "3");
_limit.AppendMenuItem(MF_STRING, 305, "5");
_limit.AppendMenuItem(MF_STRING, 310, "10");
_limit.CheckMenuRadioItem(301, 310, window.GetProperty("limit"));
_album.AppendMenuItem(MF_STRING, 490, "Small");
_album.AppendMenuItem(MF_STRING, 600, "Large");
_album.CheckMenuRadioItem(490, 600, window.GetProperty("album_img_size"));
_menu.AppendMenuItem(g_metadb ? MF_STRING : MF_GRAYED, 11, "Download artist art from Last.fm");
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _limit.ID, "Limit");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(artist_img? MF_STRING : MF_GRAYED, 12, "Open containing folder");
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _cycle.ID, "Cycle");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _album.ID, "Cover image size");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 99, "Properties");
_menu.AppendMenuItem(MF_STRING, 100, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 200:
case 205:
case 210:
case 220:
window.SetProperty("cycle", idx);
cycle = idx - 200;
break;
case 301:
case 303:
case 305:
case 310:
window.SetProperty("limit", idx);
limit = idx - 300;
break;
case 490:
case 600:
window.SetProperty("album_img_size", idx);
album_img_size = idx - 400;
window.Repaint();
break;
case 11:
WshShell.Run("\"" + script_path + "art.exe\" \""  + artist + "\" \"" + folder + "\" " + limit, 0, true);
on_playback_new_track();
break;
case 12:
WshShell.Run("explorer /select," + artist_image_path);
break;
case 99:
window.ShowProperties();
break;
case 100:
window.ShowConfigure();
break;
}
_menu.Dispose();
_cycle.Dispose();
_limit.Dispose();
_album.Dispose();
return true;
}

function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }


Edit: and another one: using marc2003's "Playback Buttons", how would I go about adding other buttons (mainly 'media library search' and 'playback statistics/rate/5')? I need the "function(){fb.XXX()" bit.

WSH Panel Mod script discussion/help

Reply #257
Could a mod please remove my previous comment? It's no longer relevant.

Nevermind the previous questions, I managed to find a workaround for my design. What I'd still like to know is if it's possible to add a background jpg/png to the "now playing" and "artwork 3in1" panels.

WSH Panel Mod script discussion/help

Reply #258
out of boredom i've updated my biography panel with full language support as an option accessible via the context menu. it now caches the text indefinitely and it won't automatically update when you switch language. to update, you have to use the context menu. (it still automatically downloads when no biography exists)



http://cid-649d3bfeaf541fbb.skydrive.live....ide/samples.zip

WSH Panel Mod script discussion/help

Reply #259
Thanks a lot! I was able to change the language based on your helpful comment, but this is nicer.

WSH Panel Mod script discussion/help

Reply #260
i just had to re-upload it because i got the code for sweden wrong. i doubt this will affect many people here but you never know.

WSH Panel Mod script discussion/help

Reply #261
Hi marc.

I'm trying to integrate one of your scripts (artwork 3in1) into tedgo's DarkOne v2.0 but I get the following error:
Code: [Select]
Scripting Engine Initialization Failed (GUID: FF1A308A-F5B2-49E1-B98F-594F180E0BA6, CODE: 0x80020101)
Check the console for more detailed information (Always caused by unexcepted script error).
In the console I see:
Code: [Select]
WSH Panel Mod (GUID: FF1A308A-F5B2-49E1-B98F-594F180E0BA6): Parsing file "C:\Programmi\foobar2000\scripts\marc2003\v2\common.js": Failed to load
Error: WSH Panel Mod (GUID: FF1A308A-F5B2-49E1-B98F-594F180E0BA6): Errore di run-time di Microsoft JScript:
'settings_path' non è definito
Ln: 6, Col: 1
<source text only available in compile time>
which basically means the variable settings_path is undefined. I tried investigating and discovered it should be set in common.js but its inclusion seems to be commented in all your scripts, so perhaps I shoud set it elsewhere.

Can you assist me?

TIA.

Alessandro

WSH Panel Mod script discussion/help

Reply #262
you need to extract the "scripts" folder from my download into your foobar folder. that is in the readme. 

WSH Panel Mod script discussion/help

Reply #263
Thanks for taking time to reply.

Please forgive my newbieness but what do you mean exactly? My foobar folder is C:\Programmi\foobar2000 and I extracted you zip in C:\Programmi\foobar2000\scripts, so I now have the following structure:

- C:\Programmi\foobar2000\scripts\other WSH samples (new)
- C:\Programmi\foobar2000\scripts\scripts\marc2003
- C:\Programmi\foobar2000\scripts\scripts\marc2003\v2

Is that correct?

Regards.

Alessandro

Never mind: got it. Apologies for wasting your time.

WSH Panel Mod script discussion/help

Reply #264
i meant the "scripts" folder from the zip should go inside your foobar folder. like this

- C:\Programmi\foobar2000\scripts\marc2003
- C:\Programmi\foobar2000\scripts\marc2003\v2

edit: you sorted it. good stuff.

WSH Panel Mod script discussion/help

Reply #265
Oh my, I'm really embarassed: I extracted the zip directly into the foobar folder (not in the scripts subfolder) and it seemed to work, but after restarting foobar I'm back to square one.

What am i missing?

Alessandro

Edit: ok, it's official: I'm DUMB. Sorry.

WSH Panel Mod script discussion/help

Reply #266
removed. wrong topic. sorry

WSH Panel Mod script discussion/help

Reply #267
Hi marc,

me again, apologies for being a PITA.

I'm using your artwork 3in1 and it works fine in Artreader mode both for Front and Artist image (I don't use Back, Disc and Icon). As it worked right out of the box, I suppose it uses the settings found in Preferences -> Display -> Front Cover & Artist tabs.

I didn't manage to make the Cycle Folder option work, though: in Set Cycle Folder I entered the same string I have in the above mentioned Artist tab:
Code: [Select]
E:\My Music\artists\substr(%artist%,1,1)\%artist%_*.*
but no image is shown. Am I misunderstanding how this option works?

Would it be possible to let it cycle using the same sources of Artreader mode (which, in my case, would mean showing the front cover and the artist image(s) at regular intervals)?

Thanks.

Alessandro

WSH Panel Mod script discussion/help

Reply #268
typo? that should be $substr. or you could use $abbr(%artist%) instead.

WSH Panel Mod script discussion/help

Reply #269
typo? that should be $substr. or you could use $abbr(%artist%) instead.
Yep that was a typo here (looks like I'm not even able to copy and paste, geez).

I re-checked (and re-copied) and the Cycle folder contains exactly the same string as the Artist tab in preferences:
Code: [Select]
E:\My Music\artists\$substr(%artist%,1,1)\%artist%_*.*
Also tried $abbr (thanks for the tip, didn't know that):
Code: [Select]
E:\My Music\artists\$abbr(%artist%)\%artist%_*.*
but doesn't seem to make any difference.

Alessandro

PS: oh, and Cycle IS set to 5 secs, not off.

WSH Panel Mod script discussion/help

Reply #270
@mobyduck
As you wrote you use DarkOne v2.0, i enhanced my cover panel to auto-cycle artreader or up to 5 custom pictures.
Maybe you want to try it instead: http://pastebin.de/4550
Cycle-Interval can be changed by right-click --> Properties "Auto Cycle Image Interval in s" (its preconfigured to 15s like Biography view panel).

Btw. how is your correct path named? $abbr(%artist%) gives DM for Depeche Mode, but A for Abba.

WSH Panel Mod script discussion/help

Reply #271
oh sorry. that's me confusing things. go back to $substr if it's just the first letter. i thought that's all $abbr did as well.

WSH Panel Mod script discussion/help

Reply #272
Thanks both for your assistance.

Yes, in my case $substr is the correct function to use: thanks for the clarification.

@tedgo: I tried your script but it appears only to cycle between the front cover and the FIRST artist image (and yes, I have more that one image for the current artist). What else should I check?

Regards.

Alessandro

 

WSH Panel Mod script discussion/help

Reply #273
Oh, yes it only cycles the first image found.
Sorry, its by design of the panel...
I don't wanted to rewrite it completely.

But you could add up to 5 images as "Custom Pictures" and cycle between them (right-click in the panel --> Properties and type-in the paths to the 5 images to the according "Picture x").
The panel can only cycle between album art OR custom pictures, not all in a row.
Maybe i change this behaviour but i guess not...

WSH Panel Mod script discussion/help

Reply #274
Oh, yes it only cycles the first image found.
Sorry, its by design of the panel...
I don't wanted to rewrite it completely.
Oh, I see...

Well, perhaps I should go back to the old albumart panel: after all it worked well for me and didn't cause any crashes. I'll try and study if and how it can replace your wsh panel.

Thanks again.

Alessandro