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: JScript Panel script discussion/help (Read 290434 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #225
I use it primarily as a source for internal Album Art Viewer. So quality is not really bother me, just too lazy to search.
It downloads now only one picture 300x300, but i need biography and other stuff. Don't see the point to use 2 plugins with same functionality. I waited half year for update or something, time to move on i guess.

Re: JScript Panel script discussion/help

Reply #226
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.

Re: JScript Panel script discussion/help

Reply #227
As to arrays, are they so slow that they should be avoided in JScript Panel scripts?
No, as marc2003 said you should be fine. This is just one factor which makes WSH slower than a modern JavaScript engine. You probably should not try to use asm.js code in scripts though.

Re: JScript Panel script discussion/help

Reply #228
You probably should not try to use asm.js code in scripts though.

That shouldn't be a problem. I'm still basically a JavaScript noob, and I had to go look up what asm.js is.

Re: JScript Panel script discussion/help

Reply #229
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.

It'd be really great if you could get that going marc2003.  I finally got around to putting together a build based on br3tt's old Kameleon using his new jscript smooth playlist panels and a number of yours including the last.fm bio script.  It'd be really nice to have it auto-download album art.  I'll get back here to post a few questions in a new thread.
Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #230
No album art yet but I have posted some other updates.

Quote
Thumbs: Download limits have been increased and the default has been reset to 10. Also, automatic downloads are now an option but turned off by default. Simply use the right click menu to enable.

Automatic downloads only trigger when the following conditions are true:

  • a new track begins and the artist is different from the previous track
  • there are no existing images. Use the Download now option if you want to check for more.
  • the last automatic check was more than an hour ago. Timestamps are maintained by the script to prevent unnecessary requests if there were no images found previously.

Musicbrainz: Now attempts to retry up to 5 times on failure.

https://github.com/19379/js-marc2003/releases

Also, I just want to make one thing very clear.... there is no support if automatic downloads don't work for you. Simply use another script/software/fix it yourself/whatever.  ;D

It should work with dynamic stream changes but I haven't tested that. It would be good to get some confirmation on that.

Re: JScript Panel script discussion/help

Reply #231
Thumbs.txt in v3.0 is identical to thumbs.txt in v2.7??  ???
Geopoliticus Child Watching the Birth of the New Man

 

Re: JScript Panel script discussion/help

Reply #232
Correct. All the changes are to files inside the js_marc2003\js folder.

edit
: I just realised my wiki page was poorly worded so I've updated it.

Quote
Unlike previous versions, updates must be downloaded manually. Just extract the whole zip contents in to your existing js_marc2003 folder and overwrite the old files when prompted. On the rare occasion a script inside a panel needs updating, it will be mentioned on the releases page.

https://github.com/19379/js-marc2003/wiki/Updates-&-Support

You should be able to tell from the new right click menu options:



Re: JScript Panel script discussion/help

Reply #233
I'll take a look at the last.fm website later and see if it's an easy fix. If it's just a few lines of code, I can post an update.


I noticed, that your thumbs script keep rotating images, insted it stops and start again when download is finished..
If you need, here is fix for that(you can figure it out):

Code: [Select]
 
//Download Image
function download()
{
try {
if (lfm_folder=="<default>") {folder = fbfolder + "\\" + p.clean_filename(p.artist) + "\\";}
if (lfm_folder=="") {folder = fbfolder + "\\" + p.clean_filename(p.artist) + "\\";}
if (lfm_folder.indexOf(":\\") > 0) {folder = lfm_folder + "\\" + p.clean_filename(p.artist) + "\\";}
}catch (err) {{fb.trace("Biography Photos: " + "TypeError: 'folder path' undefined");} var folder;}
if (!p.fso.FolderExists(folder)) return;
{
        if (p.artist == "" || p.artist == "?") return;
       
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 (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
                   
                    try {
                   
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 = 1; i < data.length; i++) {
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/avatar170s/") == 0) urls.push(data[i].src.replace("avatar170s", size == "low" ? "300x300" : size == "medium" ? "500x500" : size == "high" ? "_" : "_"));
}
                   
for (i = 0; i < Math.min(urls.length, im.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,false);
                    }
                   
                    //Update Images--------------------------------------------
                    var cicleTimerStarted2 = false;
                    var cicleTimer2 = null;
                   
                    //Start Timer 2 (Func)
                    (function startTimer2(){
                    if(!cicleTimerStarted2){
                    cicleTimer2 = window.SetInterval(function() {on_timer();}, "500");
                    cicleTimerStarted2 = true;
                    }})();
                   
                    //Stop Timer 2 (Func)
                    function stopTimer2(){
                    if(!cicleTimerStarted2) return;
                    window.ClearInterval(cicleTimer2);
                    cicleTimer2 = undefined;
                    cicleTimerStarted2 = false;
                    }
                   
                    //Definitions
                    var pos = 0;
                    if(urls.length<im.limit) {var num = urls.length;}
                    else
                    if(urls.length>im.limit) {var num = im.limit;}
                   
                    //*On Timer*
                    function on_timer(id) {
                    if(cicleTimer2 && id == cicleTimer2.ID){

                    //Check Files on Timer
                    var list = utils.Glob(folder + "\\*.jpg").toArray();
                    var a = [];
                    //fb.trace("files: " + list);
                    for (i = 0; i < list.length; i++) {
                    if (list[i]) a.push(list[i]);  
                    }
                   
                    //Length
                    l = list.length;
                   
                    //Update On First Down.(Keep Position)
                    if(im.images.length==0 && l>0) {
                    im.update();
                    pos = list.toString();
                    if(pos.indexOf("_0")>0) {pos=0;}
                    else
                    if(pos.indexOf("_1")>0) {pos=1;}
                    else
                    if(pos.indexOf("_2")>0) {pos=2;}
                    else
                    if(pos.indexOf("_3")>0) {pos=3;}
                    else
                    if(pos.indexOf("_4")>0) {pos=4;}
                    else
                    if(pos.indexOf("_5")>0) {pos=5;}
                    }
                   
                    //Stop Main Timer
                    stopTimer();
                   
                    //Wait Untill All Images Are Down.
                    if(l<num) {return true;}
                   
                    //Update All Images
                    im.update();
                    window.NotifyOthers("images", "update");
                   
                    //Keep Image Position
                    im.index=pos;
                   
                    //Stop Timer 2
                    stopTimer2();
                   
                    //Start Main Timer
                    startTimer();
                    return false;
                    }}
                    //End Of Update--------------------------------------------

                    im.doc.close();
                    } catch (err) {im.doc.close();}

    } else {
p.console("HTTP error: " + this.xmlhttp.status);
}}}}}

Re: JScript Panel script discussion/help

Reply #234

Re: JScript Panel script discussion/help

Reply #235
Correct. All the changes are to files inside the js_marc2003\js folder.

Very, very nice marc2003.
Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #236
I have four playlists which among them should contain every track in my library. To make sure of that, I post the number of tracks in each playlist along with their total and compare the total to the number of tracks in the Album List. I had been getting the latter figure by opening Properties on the All Music entry at the top of the list and reading the number of items listed in the title bar, but thought there must be a way to let my script retrieve it. This is what I came up with...

Code: [Select]
LibraryTotalTracks = fb.GetLibraryItems().count;

..but in testing, I've determined that fb.GetLibraryItems() gets handles for the tracks in the playlists rather than the Album List as I had led myself to believe. (I thought Library != Playlists. Oops!)

Is there a method to get the Album List number of tracks? Or do I need to revert to stare-and-compare?

Re: JScript Panel script discussion/help

Reply #237
..but in testing, I've determined that fb.GetLibraryItems() gets handles for the tracks in the playlists rather than the Album List as I had led myself to believe. (I thought Library != Playlists. Oops!)

I suggest you go away and test again. For you to think fb.GetLibraryItems has anything to do with playlist contents is quite insulting.

Remember that you need to use the on_library_items_added and on_library_items_removed callbacks if you want to track changes while foobar is running.

Re: JScript Panel script discussion/help

Reply #238
I suggest you go away and test again. For you to think fb.GetLibraryItems has anything to do with playlist contents is quite insulting.
I'm sorry if you feel insulted, as that is never my intent, but that is what it looked like to me. I'm still relatively new at both JavaScript and foobar, so I'm going to be confused on occasion. It's a good thing I learn from my mistakes, because I make a lot of them. And hey, I was right about fb.GetLibraryItems in the first place; I just blew the call on my results.

Quote
Remember that you need to use the on_library_items_added and on_library_items_removed callbacks if you want to track changes while foobar is running.
I didn't really know that in the first place, so memory couldn't have served. The problem is that I use Notepad++ to keep documentation files open for reference, but I didn't have Callbacks.txt onboard and didn't realize what I was missing. I would have searched on 'library' (which is how I found fb.GetLibraryItems), found the callbacks mentioned and, because on_playlist_items_added and on_playlist_items_removed are already in the script, would probably have eventually figured I needed those, too.

I wonder what the hell else I'm missing.

Anyway, thanks for setting me straight on the missing callbacks. I'll add them in, rip more CDs and see what I get.

Re: JScript Panel script discussion/help

Reply #239
No album art yet but I have posted some other updates.

Quote
Thumbs: Download limits have been increased and the default has been reset to 10. Also, automatic downloads are now an option but turned off by default. Simply use the right click menu to enable.

Automatic downloads only trigger when the following conditions are true:

  • a new track begins and the artist is different from the previous track
  • there are no existing images. Use the Download now option if you want to check for more.
  • the last automatic check was more than an hour ago. Timestamps are maintained by the script to prevent unnecessary requests if there were no images found previously.

Musicbrainz: Now attempts to retry up to 5 times on failure.

https://github.com/19379/js-marc2003/releases

Also, I just want to make one thing very clear.... there is no support if automatic downloads don't work for you. Simply use another script/software/fix it yourself/whatever.  ;D

It should work with dynamic stream changes but I haven't tested that. It would be good to get some confirmation on that.
my artist arts don't get downloaded at all, I even emptied the wsh_data folder, the bio got downloaded, but not the arts
is there any way to troubleshoot this ? I'm new to this foobar thing

Re: JScript Panel script discussion/help

Reply #240
my artist arts don't get downloaded at all, I even emptied the wsh_data folder, the bio got downloaded, but not the arts
is there any way to troubleshoot this ? I'm new to this foobar thing

Oh jeez never mind, turns out my .vbs file needed to be re-associated

btw there is no edit button for the post here ?

Re: JScript Panel script discussion/help

Reply #241
File associations shouldn't even matter because my script calls cscript.exe with the full path to the vbs file.

BTW, you can only edit during the first hour after posting. It's hidden away under the More button at the bottom right of each your posts.

Re: JScript Panel script discussion/help

Reply #242
I dunno what that cscript.exe is but I ran that whole command "csript //nologo "download.vbs" "url" "filename" and got the error "input error:there is no script engine for file extension ".vbs"" in command prompt
so I re-associate it with "assoc .vbs=VBSFile" and it's working the way it should be

Re: JScript Panel script discussion/help

Reply #243
That's weird. I just associated vbs files with Notepad++ and my script still works for me.

edit: just checked with assoc and it still says VBSFILE..

Code: [Select]
.vbs=VBSFile

I guess this goes beyond what I know about.  :-X

Re: JScript Panel script discussion/help

Reply #244
Yea I just did the same experiment as you and it worked too. I guess it's another kind of association that was lost due to the long time use of windows (I haven't reinstalled since 2009).

Re: JScript Panel script discussion/help

Reply #245
It seems the echonest have shut down their API so I've removed the script from my package. Also, my thumbs script has been updated so it only downloads automatically when playing.

https://github.com/19379/js-marc2003/releases

Re: JScript Panel script discussion/help

Reply #246
Is it possible with a JScript panel script to utilize Windows API calls?

I seem to remember that since it uses the scripting engine, this was possible.

The reason why I ask is that I have constructed a panel layout using a Panel Stack Splitter to split that panel in several sections (2 rows of 3) to house some Channel Spectrum panels.

Now for the effect I am after, these Channel Spectrums need to have their border property set to to None. But the Panel Stack Splitter itself does not have an option to set the border style.

So I was thinking, if a JScript can access the Windows API, I could insert a very small JScript panel into this layout (got some playroom) to set the border style of the container Stack Panel to Static Edge (equals the "Grey" style from the border style dropdowns)

PS. hehe, was enumeriting the Foobar window to see if there's even a border style that could be set and noticed the developer(s) probably had some difficulties with certain panel groups :) saw some names like ..._STATUS_PAIN... and ..._TOOLBAR_PAIN :p

PS; I realize trial & error could possibly get me the answer, but I can barely manage to modify an existing script to do what I want, let alone write one from scratch. I don't mind going that route but then I would like to know up front if this is possible from within a JScript panel. Wouldn't want to spent a lot of time trying to master the intricacies of the JScript Panel only to find out it isn't possible.

Re: JScript Panel script discussion/help

Reply #247
Why not use the edge style options built in to the channel spectrum component? As for everything else, the answer is no.

Re: JScript Panel script discussion/help

Reply #248
Why not use the edge style options built in to the channel spectrum component?
Well, that's exactly what I didn't want to do since that kills the effect I was going for...
it also looks ugly having a bunch of little rectangular edges inside the main panel.
So I guess I have to stick with the ugly metro look for that panel. Flat....

thanks for preventing a wild goose chase.

Re: JScript Panel script discussion/help

Reply #249
You can probably mimic the effect by using $drawrect in your PSS.