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 1401842 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #3300
The changeover to readable folder names from $crc32 folder names I think is an improvement in the long run, in part because it makes it easier to find artist strings in one's library or image folders with problems.

I found that the following facets filters were helpful in tracking down folders that didn't migrate:

artists with leading or trailing spaces:  artist IS " *" OR artist IS "* "
artists with double spaces:                  artist HAS "  "

In most cases of hits from the above filters, I had a tag field problem and I fixed them.  In some cases, the error was on the last.fm source - I had few enough of them that I just corrected the bad image file names manually.  For example, on the folders not migrated, I ran *.* as a windows explorer search and then sorted by name to find artists on last.fm that had leading spaces. Same thing with weird characters and case sensitivity - I found it more efficient to just manually scroll through the  new and remaining folders to find anomalies and make manual corrections as needed than try to figure out a script change to do the same.

I also think some of my migration problems with non-english characters were related to character set weirdness on my computer that I first noticed in using the biography component that I explored with Romor that were just easier to resolve manually in this transition.

Since it's just a one-time transition, the migration filtering that marc2003 provided was appropriate to identify potential issues and then cleanup the exceptions manually. For me, anyway.  Once you've convinced yourself the remaining unmigrated artists are accurate but from streams (artists not in your library) and you want to keep these images, only then does doing a brute-force scraping from image names to create a new folder make sense to me. And worked well for me.

WSH Panel Mod script discussion/help

Reply #3301
I agree that the new artist name based folders are better than the CRC method. In fact, I've wanted it for years! I even requested marc2003 put "open containing folder" in the panel long ago to help find the artist photos.  So well done marc2003!

Having said that, going thru my playlists, I noticed that most of the artists with "." in the naming didn't get migrated. This happens a lot for me due to the current trend of artist "featuring" artist songs which is usually written as "feat." or "ft." in the tags. Example: Jennifer Lopez feat. Iggy Azalea

As mentioned before, playing the song will download new photos. So its not a concern for me but might help with the updating the script.

WSH Panel Mod script discussion/help

Reply #3302
@marc2003
I'm getting heavy CPU usage with the new thumbs script when downloading photos from last.fm.  Sometimes hitting 100% and causing foobar to stutter or stop playing.
There seems to be a noticeable improvement in download speed for photos. It used to be a definite wait between photos downloads. Now all 5 seem to download almost immediately. But i think the cost is too high CPU usage.

FYI. I'm running Win7 on 2.40GHz CPU Dual-Core

WSH Panel Mod script discussion/help

Reply #3303
periods don't seem to be an issue for me. ah, the issue is they can't have spaces after them. more fun to workaround.

i've not even changed the download side of things so i don't know what is happening there. i guess i'll have to look into it.

edit: having a quick glance, i can't even see anything happening CPU wise with the image downloads. and i'm running a seriously ancient socket754 athlon64 with 1GB ram/XP.    the download processes are actually launched completely independently of foobar. the reason 5 spawn at once is because a previous version did do 1 at a time and waited for 1 to finish before starting the next. the problem with that is that it prevented foobar from closing which i thought was unacceptable.


WSH Panel Mod script discussion/help

Reply #3305
the reason 5 spawn at once is because a previous version did do 1 at a time and waited for 1 to finish before starting the next. the problem with that is that it prevented foobar from closing which i thought was unacceptable.

Maybe to set delay in vbs?

...I modified your old bio text script, to download biography directly from last.fm web page.
Seems to work fine

Code: [Select]
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
DT_END_ELLIPSIS = 0x00008000;

ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
};

FontTypeCUI = {
items: 0,
labels: 1
};

ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
};

FontTypeDUI = {
defaults: 0,
tabs: 1,
lists: 2,
playlists: 3,
statusbar: 4,
console: 5
};

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function get_font() {
if (g_instancetype == 0) {
g_font = window.GetFontCUI(FontTypeCUI.items);
} else if (g_instancetype == 1) {
g_font = window.GetFontDUI(FontTypeDUI.defaults);
}
}

function get_colors() {
if (g_instancetype == 0) {
g_textcolor = window.GetColorCUI(ColorTypeCUI.text);
g_textcolor_hl = window.GetColorCUI(ColorTypeCUI.text);
g_backcolor = window.GetColorCUI(ColorTypeCUI.background);
} else if (g_instancetype == 1) {
g_textcolor = window.GetColorDUI(ColorTypeDUI.text);
g_textcolor_hl = window.GetColorDUI(ColorTypeDUI.highlight);
g_backcolor = window.GetColorDUI(ColorTypeDUI.background);
}
}

function on_playlist_switch() {
on_item_focus_change();
}

function on_colors_changed() {
get_colors();
window.Repaint();
}

function on_font_changed() {
get_font();
window.Repaint();
}

function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
try { on_metadb_changed(); } catch(e) {}
window.WatchMetadb(g_metadb);
}
}

g_instancetype = window.InstanceType;
get_font();
get_colors();


g_metadb = fb.GetFocusItem();
var artist = g_text = '';
folder = fb.ProfilePath + "wsh_lastfm";
fso = new ActiveXObject("Scripting.FileSystemObject");
WshShell = new ActiveXObject("WScript.Shell");
if(!fso.FolderExists(folder)) fso.CreateFolder(folder);
on_item_focus_change();

String.prototype.count=function(s1) {
return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}

function get_bio() {

if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(artist) + "/+wiki", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (this.xmlhttp.readyState == 4) {
if (this.xmlhttp.status == 200) {
var text = this.xmlhttp.responsetext;
if (!this.doc) this.doc = new ActiveXObject("htmlfile");
this.doc.open();
var div = this.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];
for (i = 0; i < 1; i++) {
if (data[i].id.indexOf("about:/wiki/") == 0);

                   
            var st = text.indexOf( data[i].id.replace("about:/wiki/", ""));
            var str = "id=\"wiki\">";
            st = text.indexOf(str, st) + str.length;
            var et = text.indexOf("</div>", st);
            var artt = text.substr(st, et - st);
            var ar = artt;
               
            var ar = ar.replace(/<\/?[^>]+(>|$)/g, "").replace(/\n/g, "<br>").replace(/<BR>/g,"\n").replace(/&amp;/g,"&");
            fb.trace("bio: " + ar);
            {save_file(ar);};
                }
                   
                this.doc.close();
               
} else {
fb.trace("HTTP error: " + im.xmlhttp.status);
}}}}

function save_file(x) {
try {
g_text = x;
g_text = g_text.replace(/<\/?[^>]+(>|$)/g, "");
doc = new ActiveXObject("htmlfile");
doc.open();
div = doc.createElement("div");
div.innerHTML = g_text;
g_text = div.innerHTML;
g_text = g_text;
} catch(e) {
g_text = "This artist does not have a biography";
}
try {
ts = fso.OpenTextFile(filename, 2, true, -1);
ts.WriteLine(g_text);
ts.close();
} catch(e) {
g_text = "Error saving biography for this artist";
}
calc();
}

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

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
if(g_metadb) {
gr.GdiDrawText(g_text, g_font, g_textcolor, 6, offset + 8, ww-16, wh-offset-16,DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
gr.FillSolidRect(-1000, -1000, ww, 38, g_backcolor);
//gr.GdiDrawText(artist, gdi.Font("Segoe UI", 16, 1), g_textcolor_hl, 6, 5, ww-77, 24,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
//gr.DrawLine(5, 29, ww-10, 29, 1, RGB(137,140,149));
}
}

function on_playback_new_track() {
on_item_focus_change();
}

function on_metadb_changed() {
if(!g_metadb || artist == fb.TitleFormat("%artist%").EvalWithMetadb(g_metadb)) return;
artist = fb.TitleFormat("%artist%").EvalWithMetadb(g_metadb)
filename = folder + "\\" + fb.TitleFormat("$crc32(%artist%).txt").EvalWithMetadb(g_metadb);
if(fso.fileExists(filename)) {
try {
ts = fso.OpenTextFile(filename,1, false, -1);
g_text = ts.ReadAll();
ts.close();
} catch(e) {
g_text = "Error opening file!";
}
calc();
} else {
get_bio();
}
}

function calc() {
temp_bmp = gdi.CreateImage(1, 1);
temp_gr = temp_bmp.GetGraphics();
arr = temp_gr.GdiDrawText(g_text, g_font, g_textcolor, 0, 0, ww, wh,DT_CENTER| DT_WORDBREAK | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX).toArray();
textheight = arr[3] - arr[1] + (wh/2) + (g_text.count("\n") * 3);
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
offset = 0;
window.Repaint();
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Force update");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
if(idx == 1) get_bio();
if(idx == 2) window.ShowConfigure();
_menu.Dispose();
return true;
}

function on_mouse_wheel(delta) {
step = g_font.height * 1;
offset += (delta * step);
if(offset > 0 || textheight < wh) {
offset = 0;
} else {
temp = -textheight + wh;
if(offset < temp) offset = Math.round(temp / step) * step;
}
window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #3306
i still can't see anything wrong with downloads and i'm using a 10 year old piece of crap pc with an even worse 3G internet connection. i'm looking at task manager and foobar isn't using any cpu at all. 5 instances of cscript.exe are spawned to run a bit of vbscript i found online and they barely use 1-2% each for a second or 2???

WSH Panel Mod script discussion/help

Reply #3307
And i don't know to tweak my code to show both types of files...


try this.

Code: [Select]
$puts(path.artistPath,$if($fileexists(Z:\artists pictures\%artist%.jpg),Z:\artists pictures\%artist%.jpg,$if($fileexists(Z:\artists pictures\%artist%.png),Z:\artists pictures\%artist%.png,$get(path.noartist)))


and please post in bio component thread with any more issues. this is bit off topic for in here.


i think this part of the code is corrupting my panel:

Code: [Select]
$puts(text.artist,$if($fileexists(Z:\artists pictures\%artist%.jpg),%artist%,$get(text.noartist)))


Mmmm. oohh! i'm sorry i thought it were
more or less, minus is best

WSH Panel Mod script discussion/help

Reply #3308
i still can't see anything wrong with downloads and i'm using a 10 year old piece of crap pc with an even worse 3G internet connection. i'm looking at task manager and foobar isn't using any cpu at all. 5 instances of cscript.exe are spawned to run a bit of vbscript i found online and they barely use 1-2% each for a second or 2???


I've tried rebooting and still get the CPU spikes when I use the thumbs.txt. Its very repeatable for me. I just have to click on the "download artist art...".
Obviously if I'm doing something else while the foobar is playing in the background, the spike is worse and causes the stuttering playback.
I installed a CPU monitor and got the following after I click. I'm assuming its the sum of all the CPU that causes the problem?  Hope this helps.
11/11/2014 14:25   conhost.exe   8028   Process terminated   Ran for 208 ms. Average CPU use 3.74%.
11/11/2014 14:25   conhost.exe   7876   Process terminated   Ran for 292 ms. Average CPU use 5.34%.
11/11/2014 14:25   conhost.exe   6472   Process terminated   Ran for 198 ms. Average CPU use 7.87%.
11/11/2014 14:25   cscript.exe   3428   Process terminated   Ran for 294 ms. Average CPU use 10.61%.
11/11/2014 14:25   cscript.exe   1064   Process terminated   Ran for 205 ms. Average CPU use 15.21%.
11/11/2014 14:24   cscript.exe   3524   Process terminated   Ran for 200 ms. Average CPU use 11.69%.
11/11/2014 14:24   conhost.exe   7876   Process launched   Parent csrss.exe (624), PATH: C:\Windows\system32\conhost.exe
11/11/2014 14:24   cscript.exe   3428   Process launched   Parent foobar2000.exe (3464), PATH: C:\Windows\System32\cscript.exe

WSH Panel Mod script discussion/help

Reply #3309
i *think* i've taken care of migrating folder names with periods in. it's not windows that has a problem with them but some of the jscript functions which i've hopefully managed to workaround.

https://dl.dropboxusercontent.com/u/2280132...emp/migrate.txt

@marc2003
Thanks for fixing the problem. I can't confirm nor deny its been fixed. I ran the latest migrate.txt but when I went to the new wsh_data folder but couldn't find any files newly created. Does your script keep the original file date?  In any case, I spent a few hours last night cleaning up my artists and filenames. So the old ones are of little value to me now.

Here is the result log.
Quote
Folders without image/txt files deleted: 0
Folders without image/txt files not deleted due to errors: 0

Folders with image/txt files to keep: 1279

Of those folders to keep, 11 were matched against artists in your library and moved successfully.
There are 1268 folder(s) remaining that don't match artists in your library.


Again, I'm not surprised by the low "moved successfully" count because I've cleaned up.  And as you mentioned, a lot of those "remaining" were cause by separate files CRC created every time i changed capitalization or spacing over the past 4 or 5 years.

Thanks again for making this process change! It's a lot easier to manage the artist info now.

WSH Panel Mod script discussion/help

Reply #3310
Obviously if I'm doing something else while the foobar is playing in the background, the spike is worse and causes the stuttering playback.


wow. i don't have anything to explain stuttering playback? each process there is running for 1/5th of a second which is nothing. i mentioned i have a crap pc now but my previous pc was slightly less crap (ivybridge pentium dual core/8GB ram/windows 7) and that could handle foobar playing without stuttering under 100% cpu load when running intensive programs like vmware workstation or games like GTA4.

WSH Panel Mod script discussion/help

Reply #3311
marc2003, please advise a correct command to locate currently playing file, (same as double click on status bar). Want to use it on left click down.

ps. why fb.RunContextCommandWithMetadb("Open containing folder", meta_focus); - make art reader script crash, temporary put that:
fb.RunContextCommand("Open containing folder");

WSH Panel Mod script discussion/help

Reply #3312
marc2003, please advise a correct command to locate currently playing file, (same as double click on status bar). Want to use it on left click down.


Code: [Select]
function() { fb.RunMainMenuCommand("View/Show now playing in playlist"); }, "Show Now Playing", true),


This is what is assigned to a button on mine. Note that this is for latest fb2k (1.3.5). It's slightly different for earlier versions.


WSH Panel Mod script discussion/help

Reply #3314
hmm.. just checked on 1.3.5 - though, it works as i want, but i am on 1.2.9. Any tricks possible?


Code: [Select]
function() { fb.RunMainMenuCommand("View/Show Now Playing"); }, "Show Now Playing", true),


No reason not to upgrade to latest, but this should work for older versions.

WSH Panel Mod script discussion/help

Reply #3315
MachineHead, it's not. nothing happened, i remember had already try it few years ago.

after 1.2.9 it loads almost a second slower, volume control is not same, fullscreen-restore is slower, and i dont like djing with folders/dlls from version to version.
As for me to 1.2.9 was not easy step to switch to, but don't see the reason for update now if my config still works well for me.

Just checked 1.3.5 - little things uncomfortable for me is still there. How can run elevated cdtect from non admin instance, how to set different spectrum bands on fullscreen mode (40 to 80), what is variable for %home_dir%, variable for internal covers in a file .. and etc..etc.. fb2000 is not a media player, it's a media files organizer.

WSH Panel Mod script discussion/help

Reply #3316
MachineHead, it's not. nothing happened, i remember had already try it few years ago.


If it is not triggering then see here: reasons. I asked Peter that this be addressed and he kindly fixed that issue.

So you have two options.

1) Untick always show notification.

2) Update to current version and use newest code.

WSH Panel Mod script discussion/help

Reply #3317
1) Untick always show notification.

hehe, works, but you already know that tray icon is important thing.. =)

what the main reason for you to update this program all the time, it's pretty stable for years already, not say about earlie versions which i just ignore as it was so square boxed and raw..

WSH Panel Mod script discussion/help

Reply #3318
ps. why fb.RunContextCommandWithMetadb("Open containing folder", meta_focus); - make art reader script crash, temporary put that:
fb.RunContextCommand("Open containing folder");


you can't be talking about my artreader script because i don't use that code. that would locate the playing/selected file?? with my artreader script, it locates the image which could be anywhere and it actually checks the file exists before trying to locate it....

Code: [Select]
    this.explorer = function(path) {
        if (path.is_file()) this.run("explorer /select,\"" + path + "\"");
    }


even this.run is coded to fail silently so it should never crash the script.

WSH Panel Mod script discussion/help

Reply #3319
marc2003,
OK, now i got it why i start playing with it, it was not about locate playing file or open in explorer media file at first, but:
if use this code, it's opening explorer but not always highlight on a image file! need to double click again if not.

Code: [Select]
a.lbtn_dblclk(x, y);

then i try to find a way to open that image another way. after, if no way doing it well, try to add some locate currently playing file and finally search for image though opening currently playing file folder, though i store images not always at the same dir. i bit awkward when decide to spend few mins to change covers for betterresolution/quality and cannot open exaclty showing image immidiately. any ideas?

WSH Panel Mod script discussion/help

Reply #3320
marc2003,

When I use old version of your script  - "last.fm & wikipedia biography.txt"  I  have bio for band "Ekseption".

But with new version  script from samples8 bio for this band is clear.



It is a bug?

 

WSH Panel Mod script discussion/help

Reply #3321
Code: [Select]
a.lbtn_dblclk(x, y);


how the double click function works depends on what version of script you're using. if you right click the panel>Configure and look at the top to see if imports common7 or common8.js

common7 always locates the file in explorer. the only time it won't point at an image is if the album art is embedded. if that is the case, it will locate the audio file itself.

common8 will open the default image viewer for the file type. windows handles this so if you've installed 3rd party programs that have taken over jpg/png file associations, they will open in that. if the art is embedded then i locate the audio file in explorer. i've added the open containing folder on the right click menu for people who want the explorer option.

Quote
i bit awkward when decide to spend few mins to change covers for betterresolution/quality and cannot open exaclty showing image immidiately. any ideas?


you should use the Refresh option on the right click menu if you edit the image during playback. the image it points at will depend on file>preferences>display>album art. it always uses the first match it finds and ignores the rest.

WSH Panel Mod script discussion/help

Reply #3322
When I use old version of your script  - "last.fm & wikipedia biography.txt"  I  have bio for band "Ekseption".


the problem here is that the first script you use will fetch the bio just fine but it leaves an entry in the internet explorer cache for 24 hours preventing the other script from fetching the bio. i don't know why it can't use the file in the internet explorer cache.

i'm stuck with IE8 so apologies if these directions don't exactly match what you see, click on tools>internet options>browsing history>delete. make sure temporary internet files is selected and you can untick everything else. click delete and you're done. reload the common8 script and it should work.


WSH Panel Mod script discussion/help

Reply #3324
ha, i don't even keep code that old so i can't check it.