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

WSH Panel Mod script discussion/help

Reply #3125
@mire777
Forget about on metadb_changed solution.
Can you test my code  please?

Code: [Select]
function on_playback_dynamic_info_track() {
    fb.trace("playback_dynamic_info_track called");
    fb.trace("Current Title");
   
    im.metadb_changed();
   
    p.console (fb.TitleFormat("%_path_raw%").Eval());
    p.console (fb.TitleFormat("%artist%").Eval());
    var url = new RegExp("http://", "i");
        if(fb.TitleFormat("%_path_raw%").Eval(true).match(url))
        {
            fb.trace("http:// url true - forcing last.fm artist image download ");
            im.download();
        }
        else
        {
           
            fb.trace("not a http:// url - ignoring ");
        }
 
}

Yes, seems that this work, but i want to 'force download' on ''focus change'' when track is not playing -if there's no images...
I use this:

Code: [Select]
function on_metadb_changed() {
    im.metadb_changed();
    if (im.images.length==0)
    {im.download();}
    else
    {}
}

WSH Panel Mod script discussion/help

Reply #3126
Does someone know is it possible trough WSH panel to display image directly from internet without downloading ''.png''?
I recently discovered that if you enter url in preferences>display>stub image path.. Album panel will load that image..

Is possible to use something like this, and then display image in WSH panel..
What will be the code?

Code: [Select]
URL url = new URL("http://userserve-ak.last.fm/serve/_/44209321.png");
Image image = ImageIO.read(url);






WSH Panel Mod script discussion/help

Reply #3127
@marc2003

With the simple text script , text file gets loaded only on_paint . Is it possible to load a text file that is created after the script is loaded while playing?

WSH Panel Mod script discussion/help

Reply #3128
text file gets loaded only on_paint.


no it isn't. as the path to the text file or folder it looks in is based on title formatting, it checks to see if that changes on tag updates, selection changes, playing new tracks or you changing title formatting settings via the script.

anyway, i've just added a Refresh command to the right click menu. right click panel>Update script.

@mire777, you can't do anything like that with WSH panel mod. maybe the gdi.Image function could be extended if you know c++. if you really don't want to save files, use a temporary location and then delete them when done.

Quote
display image directly from internet without downloading ''.png''?


i'm not a proper programmer so don't actually know for sure but i doubt this is happening. it's still going to be downloaded in the background somewhere. the same bandwidth will be used.

WSH Panel Mod script discussion/help

Reply #3129
text file gets loaded only on_paint.


no it isn't. as the path to the text file or folder it looks in is based on title formatting, it checks to see if that changes on tag updates, selection changes, playing new tracks or you changing title formatting settings via the script.

anyway, i've just added a Refresh command to the right click menu. right click panel>Update script.


@marc2003
Thanks . 
Refresh solution works OK.

WSH Panel Mod script discussion/help

Reply #3130
Quick question if I may please.. pulling hair out

Does anyone have Jscript-WSHPM.xml and Jscript-WSHPM_udl.xml language definition for Notepad++?

A fella on this blog posts said it was on the Notepad mediawiki (which is currently down) but I couldnt find any trace of it on archive.org or even a google search.

Here is the post:
http://p774.blog.fc2.com/blog-entry-26.html

If not, would anyone happen to have one for any other editor? Which editor do you use for code hinting panel mod functions? 

Thanks

WSH Panel Mod script discussion/help

Reply #3131
Hello guys!

Yesterday I noticed high CPU usage of my uh.. lets call it "control bar" (WSH panel with all sorts of buttons and seek/volume bars). So I dug into it to see what was wrong and apparently my on_mouse_move function was the reason. I decided to introduce few timers (SetInterval()/SetTimeout()) to delay the repainting of few key areas and it actually helped. However I'm not entirely sure I actually did it right...

I'll use my rating area as example, here's what I did:
Code: [Select]
var rate_timer = false;
function rating_on_mouse_move (x, y) {
    XYinRate = ((hofset <= x) && (x <= hofset + rate_w+5) && (vofset <= y) && (y <= vofset + imgw));
    if (g_metadb && XYinRate) {
        g_drag = 1;
        nrating = Math.ceil((x-hofset)/imgw);
        if (nrating > 5) nrating = 5;
        if (nrating != lrating) {
            lrating = nrating;
        }
    }
    // mouse enters stars area
    if (!rate_timer) rate_timer = window.SetInterval(function() {
        if (g_metadb && XYinRate) {
            window.RepaintRect(hofset, vofset, imgw*5, imgw+5); //Repaint RATING area;
        }
    }, 70); // 70 ms refresh rate seems smooth enough
    
    // mouse leaving stars area
    if (!XYinRate && lrating !=rating) {
        g_drag = rating;
        rate_timeout = window.SetTimeout(function() { // timeout to kill timer
            if (rate_timer) window.ClearInterval(rate_timer);
                rate_timer = false;
                window.RepaintRect(hofset, vofset, imgw*5, imgw+5); //Repaint RATING area;
        }, 150);
    };
}


So is it the right way of doing it? I'm kind of new to JScript coding so don't judge me for stupid questions please

WSH Panel Mod script discussion/help

Reply #3132
if you're using windows 8 or newer, make sure the script engine setting in the editor dialog is set to the default jscript and not jscript9. that causes silly cpu usage even with an empty on_mouse_move function.

WSH Panel Mod script discussion/help

Reply #3133
marc2003, just one question.

Is it possible to replace something in your Web Links script for one of the buttons to execute Run Service (foo_run) whenever clicked? I've tried using var viewer = fb.RunContextCommand("Run service/Open Novel"); -- which opens calibre program in my case -- but does not work as planned. Whenever the title is playing, it executes Run Service on its own, and multiple times, without me actually clicking the button.

Here's how the whole script currently looks like. I don't really have much experience with scripting, if at all, save for changing some small things, like different sites in example below, so would really appreciate some help.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common6.js"
// @name "Web Links"
// @author "marc2003, Images by komodomedia.com and mjm716"
// @version "6.2012-12-05.01"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

var p = new panel("Web Links", ["custom_background", "metadb"]);
var b = new buttons();
b.update = function() {
    if (!p.metadb) return;
    var artist = encodeURIComponent(p.eval("%artist%"));
    var title = encodeURIComponent(p.eval("%title%"));
    var album = encodeURIComponent(p.eval("%album%"));
    var fantasticfiction = "http://www.fantasticfiction.co.uk/search/?searchfor=book&keywords=" + album;
    var goodreads = "https://www.goodreads.com/search?utf8=%E2%9C%93&query=" + album;
    var wwe = "https://www.worldswithoutend.com/searchwwe.asp?st=" + album;
    var wikipedia = "http://en.wikipedia.org/w/index.php?search=" + album;
    var viewer = fb.RunContextCommand("Run service/Open Novel");
        b.buttons = {
        but1: new button(12, 5, 32, 32, {normal: "ff1.png", hover: "ff1_h.png"}, function() { p.browser(fantasticfiction); }, fantasticfiction),
        but2: new button(54, 5, 32, 32, {normal: "goodreads2.png", hover: "goodreads2_h.png"}, function() { p.browser(goodreads); }, goodreads),
        but3: new button(96, 5, 64, 32, {normal: "wwe2.png", hover: "wwe2_h.png"}, function() { p.browser(wwe); }, wwe),
        but4: new button(170, 5, 32, 32, {normal: "wiki.png", hover: "wiki_h.png"}, function() { p.browser(wikipedia); }, wikipedia),
        but5: new button(212, 5, 32, 32, {normal: "viewer.png", hover: "viewer_h.png"}, function() { p.browser(viewer); }, viewer)
    }
    window.Repaint();
}

on_item_focus_change();

function on_size() {
    p.size();
}

function on_paint(gr) {
    p.draw_background(gr);
    b.draw(gr);
}

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

function on_mouse_move(x, y) {
    b.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
    b.lbtn_up(x, y);
}

function on_mouse_rbtn_up(x, y) {
    p.rbtn_up(x, y);
    return true;
}

WSH Panel Mod script discussion/help

Reply #3134
whatever you're calling from foo_run could be called from within the script itself.

however, you could get it to work by changing this line.....

Code: [Select]
but5: new button(212, 5, 32, 32, {normal: "viewer.png", hover: "viewer_h.png"}, function() { fb.RunContextCommandWithMetadb("Run service/Open Novel", p.metadb, 8) }, "Open novel")

WSH Panel Mod script discussion/help

Reply #3135
Works like a charm.

Thank you a lot!

WSH Panel Mod script discussion/help

Reply #3136
Hello folks...

There is a problem which i can't solve by myself and google. Hope you can help.
So, I'm trying to get my artwork script to refresh by itself after i changed the artwork on an playing file:
e.g.: Tagging -> Remove pictures.

So far i tryed to get an response of almost every given callback, but wasn't successful.
Even "on_metadb_changed()" and "on_playback_edited()" will not be triggered by "Reopening played file after update: [...]".

Any suggestions on this?
Thank you for your time :]

WSH Panel Mod script discussion/help

Reply #3137
^that issue has been discussed before and i don't think we can do anything about it. IIRC, someone did discover that one/both of those callbacks can be triggered if the playlist is an autoplaylist but that isn't much use.

i'm thinking perhaps it might even be an issue with foobar itself. i'd have thought foobar would notify the component when artwork changes in the same way it does when tags are updated but this is not the case.

disclaimer: of course i'm only speculating with that last sentence. i could be completely wrong.

WSH Panel Mod script discussion/help

Reply #3138
i'd have thought foobar would notify the component when artwork changes in the same way it does when tags are updated but this is not the case.


Maybe, but I think the panel mod just does not process the event from foobar correctly.
So it's more a problem with the component - Can't imagine such a glitch within the foobar core :D

WSH Panel Mod script discussion/help

Reply #3139
So it's more a problem with the component - Can't imagine such a glitch within the foobar core


i'd have to disagree.  in my mind, i think foobar should send the same event as when tags have been updated. there's no reason at all why the component couldn't process that.

having looked at the changelog, foobar only supported the adding/removing of embedded art with version 1.1.7 and this was released after the last version of this component. if the foobar SDK has a separate callback for when embedded art has changed then obviously it won't have been implemented in the the component but to me, embedded art is just a tag so i don't see why it would need something separate.

as a workaround, you might want to consider adding your own button/menu command to the panel that refreshes the artwork. i've done this in my own scripts.

WSH Panel Mod script discussion/help

Reply #3140
having looked at the changelog, foobar only supported the adding/removing of embedded art with version 1.1.7 and this was released after the last version of this component.


Okay, you win!
Under these circumstances, your theory makes perfect sense to me :]
Maybe there is a chance to get this fixed with the currently developed version, if we report it.

WSH Panel Mod script discussion/help

Reply #3141
Actually the situation is much simpler. foobar2000 does not define or implement any callback for changed album art, no matter whether it was updated by foobar2000 itself or another application.

WSH Panel Mod script discussion/help

Reply #3142
^is there any chance it could be updated to trigger the same callback as when normal tags are updated? obviously this would only be for embedded art added/removed/modified by foobar itself. i think this makes more sense than adding anything new as all components could use it without modification.

WSH Panel Mod script discussion/help

Reply #3143
^is there any chance it could be updated to trigger the same callback as when normal tags are updated?
I cannot speak for Peter but this feels like a hack for me.
i think this makes more sense than adding anything new as all components could use it without modification.
This is not guaranteed to trigger a reload or repaint of the displayed album art. Especially components which check the changes in the metadata to avoid unnecessary repaints will not update the displayed album art. Therefore the "without modification" part of your argument is moot and introducing a separate callback would be much safer than changing the meaning of an existing one.

WSH Panel Mod script discussion/help

Reply #3144
fairy nuff. it doesn't even effect me as i don't use embedded art.  i just thought it would handy for those who do.

WSH Panel Mod script discussion/help

Reply #3145
fairy nuff. it doesn't even effect me as i don't use embedded art.  i just thought it would handy for those who do.



@Marc you are say that ''gdi.image'' can be extended to display image from net, without download?
How to do that?

I'm tryin to send url from WSH to preferences>display>stub image path
Because foobar can read url image and display it in album art panel.
But this isn't possible with WSH?

Also when i use foobar to load image from net(in album art panel), i didn't find that foobar download that image..
But, when i use WSH, same picture are downloaded in: ''C:\Users\[user]\AppData\Local\Microsoft\Windows\Temporary Internet Files'' and in ''wsh_last.fm'' folder..


Second thing, why people must to download image for artwork?
Isn't be simply solution that when you navigate trough playlist that it load images from net only for tracks that are visible on that moment, and then when you go trough playlist down it load images for second part, and so on. No needs to download images at all, i have 15gb images and this is too much..
My library constantly growing, what will be in future?

Also, why foobar doesn't have some network share site, where will be available automaticaly upload and download for artwork biography and other song info?
What i mean is that all users can be connected to this site, and when you play some song, site will collect info for that song(genre, biography, embedded art..) and share this with other? Then when you play same song you will automaticaly receive all that info..
In that way we will be independent from such sites like last.fm..
Is there any legal restriction, and is such site expensive?

WSH Panel Mod script discussion/help

Reply #3146
this is what i said before...

Quote
maybe the gdi.Image function could be extended if you know c++.


what i mean by that is that you'd have to download the source code for WSH panel mod and make an updated component.

this will still download images in the background the same bandwidth will be used. the only difference is that there won't be any temporary or cached files left behind. just because you can't see it, doesn't mean it's not happening.

with WSH panel mod as it is, you can just delete the files on a semi-regular basis to keep the size under control.


WSH Panel Mod script discussion/help

Reply #3147
I'm not sure if this is the right thread to ask, I'm having trouble sorting my albums into multiple discs. I'm using Falstaff's WSH Playlist.



So I have the tracks labelled disc number 1, 2, and total discs set to 2. For some reason it still puts all the tracks in the same album. It does sort them by disc 1, disc 2, but I want to have them split into 2 albums so it will say at the top "[disc 1/2]" then another album underneath "[disc 2/2]".

Code: [Select]
$swapprefix(%album artist%)|%date%|$swapprefix(%album%)|%discnumber%|%tracknumber%|playcount=%play_count%


This is my sort script. Is there any way I can achieve this?

WSH Panel Mod script discussion/help

Reply #3148
right place.

be sure you haven't changed the GROUP PATTERN properties of the panel, default one should contains discnumber TAG to split multi-disc albums as well ;-)



HTH

WSH Panel Mod script discussion/help

Reply #3149
You're a legend. Thanks so much Falstaff.