Skip to main content
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 42663 times) previous topic - next topic
0 Members and 8 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #250
Is there a way to get an arbitrary URL to open in a browser from FSM (or jscript)? I was thinking this was simple, then when I tried to implement it, I realized that all the times I'd seen it done required foo_run, along with pre-defined URLs.
Maybe Shell.ShellExecute will work?
Code: [Select]
const objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("https://hydrogenaud.io");

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #251
Is there a way to get an arbitrary URL to open in a browser from FSM (or jscript)? I was thinking this was simple, then when I tried to implement it, I realized that all the times I'd seen it done required foo_run, along with pre-defined URLs.

Use Wshshell.Run with WScript.Shell

Sample function
https://github.com/marc2k3/smp_2003/blob/ed613ee3875cc914ea102a763758457431cdfc25/js/helpers.js#L516

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #252
Back from my holidays, the lastfm album art downloader is not working anymore. It is an old script by marc2003 that I modified now and then. It is quite obvious that the reason is a change in the lastfm web page HTML code. It is likely a silly problem, but I'm not familiar with HTML, so maybe someone here can help me out.

The following is - as far as I understand - the relevant code which needs some change:
Code: [Select]
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js')
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');

var x = new ActiveXObject("Microsoft.XMLHTTP");
var ar = panel.tf("$meta_sep(artist,', ',' and ')");
var al = panel.tf("%album%");

x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();

var o = _.first(_.filter(_getElementsByTagName(x.responseText, "img"), {"className" : "image-list-image"}));


The issue is in the last line of the above code. It used to fetch the first of the album covers on the album lastfm page, such as this one. I've been looking at this part of the HTML code (from line 1077 in the aforementioned example page):
Code: [Select]
    <ul class="image-list">
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/829db16b90ed471cbbfe248ef08ada39" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/829db16b90ed471cbbfe248ef08ada39.webp"
                        alt="None"
                    >
                </a>
            </li>
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/72cd2e7b55604336b9003de58bf58d24" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/72cd2e7b55604336b9003de58bf58d24.webp"
                        alt="None"
                    >
                </a>
            </li>
       
            <li class="image-list-item-wrapper">
                <a href="/music/Alessandro+Alessandroni/Prisma+Sonoro/+images/d002704049d844f4ba5dcc647614a483" class="image-list-item">
                    <img
                        src="https://lastfm-img2.akamaized.net/i/u/avatar170s/d002704049d844f4ba5dcc647614a483.webp"
                        alt="None"
                    >
                </a>
            </li>
       
    </ul>


I guess the parameters in the _getElementsByTagName function do not match the page HTML code anymore, but I cannot reference it properly.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #253
Maybe Shell.ShellExecute will work?
Code: [Select]
const objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("https://hydrogenaud.io");

Use Wshshell.Run with WScript.Shell

Sample function
https://github.com/marc2k3/smp_2003/blob/ed613ee3875cc914ea102a763758457431cdfc25/js/helpers.js#L516
Thanks, guys. thisban's code worked great, but I already had Marc's helper script in my theme so I saved a line of code :)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #254
Back from my holidays, the lastfm album art downloader is not working anymore. It is an old script by marc2003 that I modified now and then. It is quite obvious that the reason is a change in the lastfm web page HTML code. It is likely a silly problem, but I'm not familiar with HTML, so maybe someone here can help me out.

The following is - as far as I understand - the relevant code which needs some change:
...

I guess the parameters in the _getElementsByTagName function do not match the page HTML code anymore, but I cannot reference it properly.
A few things:
1) The img's don't have "image-list-image" class attached to them anymore, so all images are being filtered out. You'd have to completely remove the _.filter section, or first get all "a" tags and filter by class="image-list-item" and then get all images from inside those. I haven't used those methods enough to know how to write that relevant code though.
2) Those are .webp images. Can SMP even handle those, presuming they can be scraped correctly?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #255
A few things:
1) The img's don't have "image-list-image" class attached to them anymore, so all images are being filtered out. You'd have to completely remove the _.filter section, or first get all "a" tags and filter by class="image-list-item" and then get all images from inside those. I haven't used those methods enough to know how to write that relevant code though.
2) Those are .webp images. Can SMP even handle those, presuming they can be scraped correctly?

Thanks, I'll try your suggested fixes. I don't know about the webp format yet. I wanted to fix the file download anyway, as a mean to better understand how to use the xmlhttp object. I found instructions on how to manually download the webp file as a jpg, so maybe it's possible to edit the code in order to emulate such method. Perhaps a better alternative would be to get the jpg url from the meta tag (line 65 of the HTML code in the above example page). This might be my next question.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #256
@davideleo , I think it should be fixed with the latest marc2003 scripts (https://github.com/marc2k3/smp_2003). Download them and put them in samples/complete.

@MordredKLB , SMP doesn't support .webp images.
[EDIT] MSDN indicates that there's some built-in support for .webp images, but there is no information on when and where such support is available (https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-constant-image-file-format-constants)

PS: I might have found a workaround that might allow me to work around MSVS issues.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #257
@davideleo , I think it should be fixed with the latest marc2003 scripts (https://github.com/marc2k3/smp_2003). Download them and put them in samples/complete.

Thanks for the link, but I cannot find the "Last.fm Album Art Downloader" script. As far as I know marc2003 stopped updating it since a few years, at least publicly.

However I tried fetching the jpg URL in the page metadata with this code:
Code: [Select]
let doc = new ActiveXObject('htmlfile');
doc.open();
doc.write(x.responseText);                       
var o = doc.querySelector("meta[property='og:image']").getAttribute("content");
doc.close();

The code correctly assigns the url, such as this one, to the variable "o", but the "download" visual basic script doesn't seem to like it as an argument. The code that runs the visual basic script is the following:
Code: [Select]
_runCmd("cscript //nologo " + _q(fb.ComponentPath + "samples\\complete\\vbs\\download.vbs") + " " + _q(o) + " " + _q(f), false);
where the variable "f" is the destination filename.

I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #258
The code correctly assigns the url, such as this one, to the variable "o", but the "download" visual basic script doesn't seem to like it as an argument.

Problem solved. The issue was a leftover line of the previous code (commented out in the script below) which I naively thought to be harmless.


Code: [Select]
                        let doc = new ActiveXObject('htmlfile');
                        doc.open();
                        doc.write(x.responseText);                       
                        var o = doc.querySelector("meta[property='og:image']").getAttribute("content");
                        doc.close();                     
// var u = o.src.replace("avatar170s", "ar0");
     _runCmd("cscript //nologo " + _q(fb.ComponentPath + "samples\\complete\\vbs\\download.vbs") + " " + _q(o) + " " + _q(f), false);
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #259
Hello,

When I use image in my panels, for example with gdi.Image('path.to.img'), I can't delete the file from filesystem without closing foobar2000. Is there a best practice to release image handle?
Kind regards,
Nicolas

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #260
Hi, I just noticed that when I print out the track title for example ( fb.TitleFormat('%title%'); ) the character & does not display correctly. This is what it looks like. It's not a huge deal, but it would be nice if I could fix it. And ideas?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #261
Hi, I just noticed that when I print out the track title for example ( fb.TitleFormat('%title%'); ) the character & does not display correctly. This is what it looks like. It's not a huge deal, but it would be nice if I could fix it. And ideas?
What method are you calling to print the text? Which font are you using?

 
SimplePortal 1.0.0 RC1 © 2008-2019