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

WSH Panel Mod script discussion/help

Reply #625
First, thanks to Marc and everyone else for their great scripts and tips. I've had some success tweaking various scripts to suit my needs, but I'm having trouble accomplishing one thing...

Basically I want to combine the custom folder mode from the Thumbs script and use that for the artist art in the Now Playing script. Can anyone help me achieve this?

I keep my artist art in the root folder of the artist: Music\Artist\Album\

Custom folder works perfectly for my needs I just need the option in the Now Playing script

WSH Panel Mod script discussion/help

Reply #626
you could do a quick and dirty edit of the "now playing" script, changing line 55 to something like...

Code: [Select]
folder = fb.TitleFormat("$replace($directory_path(%path%),%directory%,)").EvalWithMetadb(g_metadb);

WSH Panel Mod script discussion/help

Reply #627
Thank you that works perfectly.

WSH Panel Mod script discussion/help

Reply #628
I'm trying to figure simple way to add (or replace) variable to custom_db with WSH Panel Mod and could use some help since I have no experience with databases. Some sample code would be appreciated.

I have sqlite3.exe and foo_run present and have been trying to make some sense to marc2003's scripts but I'm afraid I will fuck something up with my db if I just copy those scripts...

WSH Panel Mod script discussion/help

Reply #629
I'm trying to figure simple way to add (or replace) variable to custom_db with WSH Panel Mod and could use some help since I have no experience with databases. Some sample code would be appreciated.

I have sqlite3.exe and foo_run present and have been trying to make some sense to marc2003's scripts but I'm afraid I will fuck something up with my db if I just copy those scripts...


you can just add actions in the settings of custom database. then in your script you can call those actions using  fb.RunContextCommand([your_action])

WSH Panel Mod script discussion/help

Reply #630
you can just add actions in the settings of custom database. then in your script you can call those actions using  fb.RunContextCommand([your_action])

Thanks. I got it working but it's kinda ugly:
Code: [Select]
function on_playback_time()
{

    if (wait == 0) newsongready = 1;

    if (newsongready == 1 && song_handled == 0)
    {
        g_metadb = fb.GetNowPlaying();
        g_metadb.UpdateFileInfoSimple("artistinfo",lastfm_data[1][1]);
        g_metadb.UpdateFileInfoSimple("albuminfo",lastfm_data[2][1]);
        fb.trace("mdbc: "+lastfm_data[1][1]+" / "+lastfm_data[2][1]);
        song_handled = 2;
        fb.trace(song_handled+fb.TitleFormat(" art: %artistinfo% alb: %albuminfo%").Eval());
    }
    else if (song_handled == 2)
    {
        if (fb.TitleFormat("$if(%artistinfo%,$if(%albuminfo%,1,0),0)").Eval() == 1)
        {
            fb.RunContextCommand("Customdb SetArtistCount");
            fb.RunContextCommand("Customdb SetAlbumCount");
            song_handled = 1;
            g_metadb.UpdateFileInfoSimple("artistinfo","");
            g_metadb.UpdateFileInfoSimple("albuminfo","");
            fb.trace(song_handled+fb.TitleFormat(" art: %artistinfo% alb: %albuminfo%").Eval());
        }
    }
}

As you see, I have to first put my data to tags, then (when it's ready) use contextmenu to store it from tags to customdb and remove tags. If somebody knows better way of doing this I would be pleased.


WSH Panel Mod script discussion/help

Reply #632
@Falstaff

I am enjoying using your Lyriks 1.3 script. However, I am having problems with the wrong characters being displayed for some lyric files. One example is below.

The initial part of the lrc file is shown below. The last line displays incorrrectly as:

I don’t think I know my way around

[encoding:windows-1250]
[ti:Your mistake]
[ar:Melanie C]
[al:This time]
[la:en]
[00:02.10]| Melanie C - Your mistake |
[00:02.70]| album: 'This time' 2007 |

[00:05.67]I should concentrate on slowing down
[00:10.33]Cause all I wanna do is drive fast
[00:13.42]I don’t think I know my way around

There are problems with other characters as well in certain lrc files. Is it possible to fix these errors? The display font is your default of Segoe UI.

WSH Panel Mod script discussion/help

Reply #633
...
The initial part of the lrc file is shown below. The last line displays incorrrectly as:

I don’t think I know my way around

...
[00:13.42]I don’t think I know my way around

There are problems with other characters as well in certain lrc files. Is it possible to fix these errors? The display font is your default of Segoe UI.


yes, some chars (ansi, non-ascii) may not be rendered as well if the lyrics are grabbed from a file from disk BUT it's OK if the lyrics are stored in the file TAG.

this is due to the fact that WSH can't (or i've not find how to do...) read non-ascii characteres ==> read file function in javascript limitations, it took the encoding mode of the system you are running with (i think)

if someone know how to fix it, i'm interrested too, btw, i store my lyrics in TAG, not on disk, so i don't encounter this problem often.

Is you example stored on disk ?

WSH Panel Mod script discussion/help

Reply #634
Yes my lrc files are stored on disk.

WSH Panel Mod script discussion/help

Reply #635
if someone know how to fix it, i'm interrested too, btw, i store my lyrics in TAG, not on disk, so i don't encounter this problem often.

Code: [Select]
iconv.exe -s -f CP1250 -t CP1252 input.txt > output.txt


iconv can be dl, i.e. from here (Binaries + Dependencies link): http://gnuwin32.sourceforge.net/packages/libiconv.htm

if lyrics are stored in tags foo_chacon would be ideal


 

WSH Panel Mod script discussion/help

Reply #637
... in the meantime I have put a replace function in to strip out unwanted characters which helps the display a lot. After line 603 I have put:

new_str = new_str.replace(/[^'-;:,.?!"&*()+=\w\d\s]/gi,'');

I am also getting the occasional crash due to a script error. This is with your unaltered code. Always it occurs when using another application and it happens when return to foobar2000.

'g_tab[...].timer' is null or not an object
Ln: 279, Col: 13
<source text only available in compile time>

Is it possible to fix this?

Other than these points it is working extremely well.

WSH Panel Mod script discussion/help

Reply #638
I am also getting the occasional crash due to a script error. This is with your unaltered code. Always it occurs when using another application and it happens when return to foobar2000.

Noticed same here unfortunatelly

And I thought your (Falstaff) question about encodings was general as I'm courious too if there is some VBS/JS conversion possible. At least conversion to ASCII or ANSI, and even only from European latin encodings (obviously if we are talking only about ASCII/ANSI)

WSH Panel Mod script discussion/help

Reply #639
As T.P mentions, he didn't consider any problem about file code when compiling WSH mod.
It's simply the problem from the component itself.
mad messy misanthropist morbid mused

WSH Panel Mod script discussion/help

Reply #640
I was thinking again on this encodings subject and two ideas come to my mind:
- dictionary object referring character original and it's Unicode representation, or
- dictionary object referring only problematic European encodings to their 'best fit' ASCII equivalent

Then parsing lyrics text object through function using above dict

Both methods should work unnoticeable, as lyrics text is small text object

I'm going to implement second one in VBS for my file manager as it can't read filenames other than my locale and has VBS extensibility

WSH Panel Mod script discussion/help

Reply #641
update to above:
There is option to do conversion with [ADODB.Stream] for which you can define [.Charset], but the problem is how can you know in which charset are source (problematic) lyrics?
So I guess best option is to do 'best fit' ASCII conversion with dictionary object

[edit] or to just strip non-ascii chars: 32 < Asc(Chr) < 125

WSH Panel Mod script discussion/help

Reply #642
So why not consider using utils.ReadTextFile()? It handles ANSI, UTF8 (with BOM) and UTF16 (with BOM) files.

WSH Panel Mod script discussion/help

Reply #643
Problem are encоdings not covered by user's code page, for example your locale/code page/ANSI representation is in CP-1252 and file is CP-1250 encoded or similar

WSH Panel Mod script discussion/help

Reply #644
I wonder if you can hide external process window and accessing its stdin at the same time. I know how to hide the window with wshshell.Run() method and accessing stdin of an external process with wshshell.Exec() method but you can't access stdin with Run() method and similarly I can't run a hidden process with Exec() method. Is it possible, and how?

I'm kinda new to javascript so any help is appreciated.


WSH Panel Mod script discussion/help

Reply #646
It's great that now there exist such a conversion function.

My point is how can you tell if lyrics file is CP1250 or CP1253 or whatever else encoded?
AFAIK there isn't smart way of knowing file encoding. You could eliminate some encodings, but it's impossible to know in which encoding is original file unless you do it visually by looking represented characters on monitor (through your code page).
For automated purpose I suggested "downsampling" to ASCII (which would work fine with some encodings). Similar to $ascii(), or even better $ansi() function in foobar TF. I overlooked in previous posts that foobar TF functions can be executed inside WSH code
IMHO all this should be leaved to user discretion, without trying to fix anything on other side. If user has lyrics files encoded in strange CP than he/she should take care of it (unfortunately I'd guess user is not aware of his lyrics file encodings, as they are mainly downloaded, shared etc.)

Maybe you can do simple check to see if file is UTF-8 encoded, then if it's not and byte stream values are not in ASCII or in user code page extended character representation, then do ASCII downsampling.

How do you plan to use this function inside your lyrics script, anyway?

WSH Panel Mod script discussion/help

Reply #647
I have made kind of intensive calculation function that takes about a minute to go through. During this foobar goes to "not responding"-state. How could I do this calculation "in the background" so it wouldn't affect the whole programs performance? (function mainly consist of one long while-loop that goes through all the tracks)

WSH Panel Mod script discussion/help

Reply #648
Problem are enc?dings not covered by user's code page, for example your locale/code page/ANSI representation is in CP-1252 and file is CP-1250 encoded or similar



try v1.4.0

http://www.hydrogenaudio.org/forums/index....st&p=733166



this download is bad for me

I can't download now

please give me another download address

WSH Panel Mod script discussion/help

Reply #649
@hejiamei:

i was not talking about my lyriks WSH script !!! but about WSH panel mod release... so there is no link to download something yet. later.