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: Spider Monkey Panel (foo_spider_monkey_panel) (Read 136641 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #850
You could avoid all out of memory errors and get webp support by using the JScript Panel version instead.

As for automatic downloads. fb2k must be playing, the selected item must match what is now playing and 2 seconds must have passed since the track was started before it even checks and there must be no existing images already.

https://github.com/TheQwertiest/smp_2003/blob/4a35bfe34a1190e5b321042fcecec9c9a5086fcb/js/thumbs.js#L175L184

It is quite literally impossible for anything to happen by selection change when not playing.





Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #851
You could avoid all out of memory errors and get webp support by using the JScript Panel version instead.

As for automatic downloads. fb2k must be playing, the selected item must match what is now playing and 2 seconds must have passed since the track was started before it even checks and there must be no existing images already.

https://github.com/TheQwertiest/smp_2003/blob/4a35bfe34a1190e5b321042fcecec9c9a5086fcb/js/thumbs.js#L175L184

It is quite literally impossible for anything to happen by selection change when not playing.
this was sometime ago, so I haven't been playing with the download part for a while. will report back if I get to the exact reproducing steps the next time I encounter this (similar to #5)

I'm stuck with the very old JScript Panel because the newer versions of JScript Panel break compatibility for scripts like Modoki Lyrics. I'm holding onto the old version of JScript Panel because of these scripts

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #852
my first attempt/edit on samples\complete\js\thumbs.js to add multiple folders support. probably breaks download and something I didn't notice
example customer folder now take multiple folder separated by newline (line feed character) $directory_path(%path%)\Scans$char(10)$directory_path(%path%)\Scans Hi-Res

  • replace all instances of this.folder with this.folders
  • add this line to the file (I added at line 2)
Code: [Select]
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
  • modify the beginning of this.update content (@ around line 495) to
Code: [Select]
    this.update = () => {
        this.image = 0;
        function iter_folder_get_files_curry(exts, newest_first){
            return function(folder){
                return _getFiles(folder, exts, newest_first);
            }
        } // end iter_folder_get_files_curry
        this.files = _.filter(_.spread(_.union)(_.map(_.union(_.split(this.folders,"\n")),iter_folder_get_files_curry(this.exts, this.properties.sort.value == 1))), _.size);
        if (this.properties.source.value == 1 && this.files.length > 1) {
            this.default_file = this.folders + utils.ReadINI(this.ini_file, 'Defaults', _fbSanitise(this.artist));
            const tmp = _.indexOf(this.files, this.default_file);
            if (tmp > -1) {
                this.files.splice(tmp, 1);
                this.files.unshift(this.default_file);
            }
        }


glob and out of memory crashes are to be explored as Spider Monkey Panel seemed to be missing the JavaScript functionalities for node-glob to work

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #853
problems with Spider Monkey Panel's utils.Glob are

1. unable to handle paths with non-English (Unicode?) character. it returns empty array if the input path pattern is not purely English ASCII
2. does not recursively go into sub-directory. doesn't support the /**/* syntax

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #854
problems with Spider Monkey Panel's utils.Glob are

1. unable to handle paths with non-English (Unicode?) character. it returns empty array if the input path pattern is not purely English ASCII
2. does not recursively go into sub-directory. doesn't support the /**/* syntax
utils.Glob is implemented using fb2k's implementation of FindFirstFile/FindNextFile. It's not a unix glob and you shoudn't expect it to behave like one.  You should also assume that any code written for node-js will not function in FSM; they're two completely different things.

If unicode paths aren't working then that appears to be a limitation of the foobar SDK. The FSM code seems to handle unicode files inside a directory, but I didn't verify. Just saw that it's checking unicode strings in the returned filePaths.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #855
I tested it and it works exactly as expected.



It exclusively lists files with Björk in the filename and omits the others.

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #856
problems with Spider Monkey Panel's utils.Glob are
2. does not recursively go into sub-directory. doesn't support the /**/* syntax

That's right, there you got recursive search. That's what I use to inject a mod into another script, looking for all js files first.

Code: [Select]
let fileArr = findRecursivefile('*.js', [fb.ProfilePath, fb.ComponentPath]); // All possible paths for the scripts

Code: [Select]
function findRecursivePaths(path = fb.ProfilePath){
let arr = [], pathArr = [];
arr = utils.Glob(path + '*.*', 0x00000020); // Directory
arr.forEach( (subPath) => {
if (subPath.indexOf('\\..') !== -1 || subPath.indexOf('\\.') !== -1) {return;}
if (subPath === path) {return;}
pathArr.push(subPath);
pathArr = pathArr.concat(findRecursivePaths(subPath + '\\'));
});
return pathArr;
}

function findRecursivefile(fileMask, inPaths = [fb.ProfilePath, fb.ComponentPath]){
let fileArr = [];
if (isArrayStrings(inPaths)) {
let pathArr = [];
inPaths.forEach( (path) => {pathArr = pathArr.concat(findRecursivePaths(path));});
pathArr.forEach( (path) => {fileArr = fileArr.concat(utils.Glob(path + '\\' +  fileMask));});
}
return fileArr;
}

function isArrayStrings(checkKeys, bAllowEmpty = false) {
if ( checkKeys === null || Object.prototype.toString.call(checkKeys) !== '[object Array]' || checkKeys.length === null || checkKeys.length === 0) {
return false; //Array was null or not an array
} else {
let i = checkKeys.length;
while (i--){
if (Object.prototype.toString.call(checkKeys[i]) !== '[object String]') {
return false; //values were null or not strings
}
if (!bAllowEmpty && checkKeys[i] === '') {
return false; //values were empty
}
}
}
return true;
}

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #857
I tested it and it works exactly as expected.
Spoiler (click to show/hide)

It exclusively lists files with Björk in the filename and omits the others.
below screenshot should illustrate the problem. you can see the contradiction between utils.IsDirectory and utils.Glob. even utils.Glob itself is not very consistent. I'm not sure if this is fb2k problem or Spider Monkey Panel's own implementation bug

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #858
problems with Spider Monkey Panel's utils.Glob are
2. does not recursively go into sub-directory. doesn't support the /**/* syntax

That's right, there you got recursive search. That's what I use to inject a mod into another script, looking for all js files first.
Spoiler (click to show/hide)

thanks. I was hoping to be able to do something like glob.sync(path + '**/*.+('+this.exts+')') to grab all files in all sub-directory recursively with the targeted extension in one shot using the regular glob

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #859
It exclusively lists files with Björk in the filename and omits the others.
ö isn't unicode -- It's ASCII value 148.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #861
Yeah, confirmed that it works just fine. @SUPERCOOLMAN is doing something wrong. Doing a console.log on utils.Glob will always return at least a "[]" even if it doesn't match anything but his console screenshot shows it returning an empty string, which tells me that somehow his code is not using the FSM utils.Glob. Maybe one of the includes is overwriting it?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #862
Yeah, confirmed that it works just fine. @SUPERCOOLMAN is doing something wrong. Doing a console.log on utils.Glob will always return at least a "[]" even if it doesn't match anything but his console screenshot shows it returning an empty string, which tells me that somehow his code is not using the FSM utils.Glob. Maybe one of the includes is overwriting it?

Spoiler (click to show/hide)
I think your problem is that you are not doing string concat (in console.log) like I had shown in my screenshot... you should try to concat something to utils.Glob's result
here is the code I used
Code: [Select]
"use strict";
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');

let panel = new _panel(true);

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( panel.tf("$directory_path(%path%)"), 0x0, 0x10 ));
console.log("directory_path=" + panel.tf( "$directory_path(%path%)" ));
console.log("utils.Glob+=" + utils.Glob( panel.tf("$directory_path(%path%)\\画像"), 0x0, 0x10 ));
console.log("directory_path+=" + panel.tf( "$directory_path(%path%)\\画像" ));
console.log("utils.Glob+=" + utils.Glob( panel.tf("$directory_path(%path%)"+"\\画像"), 0x0, 0x10 ));
console.log("directory_path+=" + panel.tf( "$directory_path(%path%)"+"\\画像" ));

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #863
Heh, you're right. Still it's you (your computer, directory name, etc.), not FSM:

Code: [Select]
"use strict"

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\*", 0x0, 0x10 )); // you can't have wildcard and then more path -- not a unix glob
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像*", 0x0, 0x10 ));// you can't have wildcard and then more path -- not a unix glob
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*\\画像", 0x0, 0x10 ));// you can't have wildcard and then more path -- not a unix glob

console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #864
Heh, you're right. Still it's you (your computer, directory name, etc.), not FSM:

Spoiler (click to show/hide)
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue

for me, I get below result with the following code
Code: [Select]
"use strict"

console.log("utils.IsDirectory=" + utils.IsDirectory("C:\\エデン\\画像"));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エ*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像", 0x0, 0x10 ));
console.log("utils.Glob=" + utils.Glob( "C:\\エデン\\画像*", 0x0, 0x10 ));
Code: [Select]
utils.IsDirectory=true
utils.Glob=
utils.Glob=C:\エデン
utils.Glob=
utils.Glob=C:\エデン\.,C:\エデン\..,C:\エデン\画像
utils.Glob=
utils.Glob=
utils.Glob=
Spider Monkey Panel v1.4.1 ({E02200A8-2D15-40A2-878C-EEEE123C71D1}): initialized in 2 ms

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #865
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue
Shouldn't be anything different in my dev build (and snotlicker already showed it works in 1.4.1). Just to be clear, you're on a Windows flavor, and not trying to run this in WINE, right?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #866
right now, I can only think of either SMP version differences (you have dev build) or my OS's native language/encoding being CJK causes some other transformation resulting the issue
Shouldn't be anything different in my dev build (and snotlicker already showed it works in 1.4.1). Just to be clear, you're on a Windows flavor, and not trying to run this in WINE, right?
I'm running this on native WIn10 20H2, not wine or any VM. also, some patterns are working for me as you can see from my results, just not all. that's why I'm not able to figure out what's wrong

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #867
is it normal that if 1 SMP crash, all SMP would crash together despite each running different script?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #868
No idea what you're trying to do but there is nothing wrong with the component. My previous examples were file based, this is just folders...


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #869
No idea what you're trying to do but there is nothing wrong with the component. My previous examples were file based, this is just folders...

Spoiler (click to show/hide)
MordredKLB had already pointed out that I'm trying to achieve unix glob.

anyways, I minimized and modified tiny-glob to had achieve what I want in SMP. next step is to see how to make it faster
Code: [Select]
Glob Pattern=C:/エデン/*画像*/**/*.{jpg,jpeg,png,gif}
Glob Pattern=C:/エデン/*圖片*/**/*.{jpg,jpeg,png,gif}
Glob Found=C:\エデン\画像\001.png
C:\エデン\画像\002.png
C:\エデン\画像\003.png
C:\エデン\画像\004.png
C:\エデン\画像\005.png
C:\エデン\画像\l2\001.png
C:\エデン\画像\l2\002.png
C:\エデン\画像\l2\003.png
C:\エデン\画像\l2\004.png
C:\エデン\画像\l2\005.png
C:\エデン\画像\l2\l3\001.png
C:\エデン\画像\l2\l3\002.png
C:\エデン\画像\l2\l3\003.png
C:\エデン\画像\l2\l3\004.png
C:\エデン\画像\l2\l3\005.png
C:\エデン\画像\l2 - 2\001.png
C:\エデン\画像\l2 - 2\002.png
C:\エデン\画像\l2 - 2\003.png
C:\エデン\画像\l2 - 2\004.png
C:\エデン\画像\l2 - 2\005.png
Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003): initialized in 376 ms

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #870
encountered another weird issue. when I added code to re-size images based on panel size, which takes a hell long time (200+ms → 10+sec), I notice _img (which calls gdi.Image) failed to load some of the images hence the resulting GdiBitmap are null. however, both utils.IsFile and _isFile confirmed these files do exists. there is no out of memory error or any error msg, so I'm not sure how to determine why images would fail to load. if I handle returning GdiBitmap being null properly with a check to let it continue, then many other images after the failing images loaded just fine

multiple other files in the same directory and similar name loaded just fine. for example, A********10.png loads just fine, but A********11.png would fail to load. A********12.png and  A********13.png load without issue as well. array is sorted order, so images would get loaded in order

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #871
Just because a file definitely exists, doesn't mean it's guaranteed to be read successfully by the gdi.Image function.

The component uses the Gdiplus library from the windows SDK and what you must do after most operations is check the status in C++.

https://docs.microsoft.com/en-us/windows/win32/api/gdiplustypes/ne-gdiplustypes-status

If the status of the operation is not OK, you get a null return value.

Reporting the internal error in this case is largely useless. See the remarks section on the web page above...

Quote
If you construct a GDI+ object and then immediately call the GetLastStatus method of that object, you can determine whether the constructor succeeded or failed. In such cases, GetLastStatus might return OutOfMemory even though there was plenty of memory available to create the object. Several GDI+ constructors set the status to OutOfMemory when they fail regardless of the reason for failure.

I'm sure you'll go on to say you can view the image in windows or any other image viewer. I can't explain that, It's way over my head.

If it only affects a few images, loading them in an editor and "saving as" might generate new files that can be read.

Regarding the time consuming resize operations, you might consider caching the results so it only has to be done once.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #872
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Photoshop will complain if the file is misnamed which is how I discovered this in the first place. Resaving files in an image editor that can open them is definitely good advice.

When you speak of speed in resizing, how big are these images in resolution and file size, and what size are you scaling them to? I do a lot of resizing from 2000x2000 (and occasionally larger) images down to pixel display size (usually around 1400x1400) and it's fast, as in always <1 second fast. It's gonna grow logarithmically though as original file size increases. I know Qwertiest used to complain how slow just loading 3000x3000 images was in JSP, and I doubt it's any faster in FSM.

Caching is definitely the way to go. Here's my implementation of an LRU ArtCache that should be fairly simple to adapt to any script.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #873
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Photoshop will complain if the file is misnamed which is how I discovered this in the first place. Resaving files in an image editor that can open them is definitely good advice.

When you speak of speed in resizing, how big are these images in resolution and file size, and what size are you scaling them to? I do a lot of resizing from 2000x2000 (and occasionally larger) images down to pixel display size (usually around 1400x1400) and it's fast, as in always <1 second fast. It's gonna grow logarithmically though as original file size increases. I know Qwertiest used to complain how slow just loading 3000x3000 images was in JSP, and I doubt it's any faster in FSM.

Caching is definitely the way to go. Here's my implementation of an LRU ArtCache that should be fairly simple to adapt to any script.

they are all 3000x3000 or 5000x2000. each file is 10MB-30MB in size. with more than 30 images to load, I guess thumb's implementation of loading every image at the beginning is slowing everything down causing the fb2k freeze. for comparison, windows and other image viewers are able to batch convert all of them in less than 2 seconds (read all files, convert and write downscaled images back all on HDD), so at least disk operations shouldn't be the bottleneck

is there anyway to load image in the background or separate thread while not freeze/holding fb2k? I had tried LoadImageAsyncV2, but that seemed to also freeze fb2k for some moments while loading images as well

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #874
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

https://github.com/marc2k3/foo_jscript_panel/blob/f03851583d109c39a5b4aafc942deacd87c2f7a7/src/Helpers/Image.h#L60-L61

Pretty sure SMP does exactly the same as the code was inherited from WSH panel mod.

edit: tested just to make sure. These are 5 gif files renamed with different extensions...


 
SimplePortal 1.0.0 RC1 © 2008-2021