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 1389012 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #3225
How would I declare an X coordinate for a volume slider position that's always N-increments away from the right edge? I managed to get it positioned vertically in the panel and length of slider is set, etc. But "p.w - N" doesn't behave quite the same as the playback buttons.

Pictures, because I suck at explaining stuff.

Static placement: https://i.imgur.com/NEf4klo.png

Dynamic attempt: https://i.imgur.com/MRMvyqV.png

WSH Panel Mod script discussion/help

Reply #3226
when the value is going to be dynamic, it doesn't really matter what you put in the new volume bit at the start because that value is only temporary. you actually need to update this value inside the on_size function. at the very bottom of your screenshot, you can see where i've defined the value of s.w which is also dynamic. you just need to add a new line after it:

Code: [Select]
v.x = p.w - v.w - 11;


i noticed you've tried 11 in your attempt but you need to remember this value is the left most edge of the volume bar. it looks like you want a gap of 11 plus the width of the bar itself.

WSH Panel Mod script discussion/help

Reply #3227
Yeah, I was trying to ferret that 11 out. Thanks again.

WSH Panel Mod script discussion/help

Reply #3228
Functions seem to be fighting with each other when the whole lot is merged into one.

WSH Panel Mod script discussion/help

Reply #3229
they should all work together. the problem is i've never documented how to do and there are no comments either.

edit: this should work... remove all functions below on_paint and replace them with this...

Code: [Select]
function on_playback_seek() {
s.playback_seek();
}

function on_playback_stop() {
s.playback_stop();
}

function on_mouse_wheel(step) {
if (s.wheel(step)) return;
if (v.wheel(step)) return;
}

function on_volume_change(vol) {
v.volume_change(vol);
}

function on_mouse_move(x, y) {
p.move(x, y);
if (s.move(x, y)) return;
if (v.move(x, y)) return;
b.move(x, y);
}

function on_mouse_lbtn_down(x, y) {
if (s.lbtn_down(x, y)) return;
if (v.lbtn_down(x, y)) return;
}

function on_mouse_lbtn_up(x, y) {
if (s.lbtn_up(x, y)) return;
if (v.lbtn_up(x, y)) return;
b.lbtn_up(x, y);
}

and i do seem to have found a bug. tooltips are only working on the seekbar. i'll try and figure that out.

WSH Panel Mod script discussion/help

Reply #3230
Thanks again. Working like it should now. I kept getting conflicts with mouse button actions before.

WSH Panel Mod script discussion/help

Reply #3231
i did announce a few months back that i wasn't supporting my discogs script anymore. at the time it was still working so anyone who already had it and didn't run Update script could keep it working.

but the changes that i knew were coming have been done in the last week. now it won't update anymore. it may still give the appearance that it's working because it will display old cached entries just fine but you'll never see any new changes to the discogs database on it. i just thought i'd give people a heads up.

to tidy up, you can browse into your foobar profile\wsh_lastfm folder, search for and delete all discogs.json files.

as an alternative, my musicbrainz script is still supported.

WSH Panel Mod script discussion/help

Reply #3232
Hi there. Recently starting to mod my skin and started to recall programming using WSH script mod.

Is there anyway to retrieve the tags in the currently playing music such as %album%? The issue here is to change the state of the playback item such as display a darkened skip icon if %SKIP% tag value is present and is 1 in the currently playing track.

This would have been easy if it were done in panel splitter as I have experience in that. E.g. $ifequal(%skip%,1,$imagebutton(...),$imagebutton(...))

WSH Panel Mod script discussion/help

Reply #3233
i don't understand. how do you expect to query a track tagged with SKIP when it's going to get um.... skipped?

if you were building some kind of playlist displaying multiple tracks then of course you could do something like that. but i doubt you're taking that on, are you? 

WSH Panel Mod script discussion/help

Reply #3234
Thanks again for all your help, Marc. This will keep me busy for a while debating on which I like best for various themes. I have more questions on how one would format item properties like in EH's FooAero theme (his info tab is lovely) but I don't wanna push my luck until I look into a bit more myself. 


WSH Panel Mod script discussion/help

Reply #3235
@marc2003,

Made a mistake in copying some things in the initial script that baffled me until I realized what the conflict was.

eg:  var p = new panel("Themed Toolbar Buttons / Simple Seekbar / Simple Volume", ["themes","custom_background"]);

Aha! Cannot have "custom_background" in a themed element as it will not do anything in the popup menu. Since changed to "themes" only in the brackets.

So now I'm curious what controls the colors in your themed examples? I'm leaning toward something defined in the common7.js but that's just a guess.

Maybe more importantly, can these examples pull the color info from within FB2K's color options so it gels with the rest of the UI? In other words - if I set background to blue in color options it changes the theme of the toolbar to match.

WSH Panel Mod script discussion/help

Reply #3236
you can have a custom background with themed buttons. it's just that particular panel is hardcoded to have a background that matches your windows theme.

you can edit your panel to change this - just find the on_paint function and remove this line...

Code: [Select]
p.themed_header.DrawThemeBackground(gr, 0, -p.h, p.w, p.h * 2);


replace it with

Code: [Select]
p.draw_background(gr);


now the background will match whatever you set in the main foobar preferences. optionally you may add "custom_background" in the initial panel declaration and your popup menu should work as before.

WSH Panel Mod script discussion/help

Reply #3237
you're both right. i tried a fresh portable install and it works. i guess some option or maybe other component is interfering on my main install? 

edit: file>preferences>display>default user interface>always show notification icon is the culprit. if i turn that off, it works as expected.


Addressed in latest.

WSH Panel Mod script discussion/help

Reply #3238
samples updated: quite a serious bug when it comes to matching results in my allmusic review script.  oops... 

this has now been fixed, right click>Update script.

full download here: https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip

this will probably be the last update for this pack as i've been messing around changing a few things for the next update.

thumbs script users wanted!

i would like some people to test my new version. i'm ditching the old wsh_lastfm folder which converted the artist name using the $crc32 function (i was incredibly lazy when i made that. ). i'm now using plain text with the correct illegal character replacement to make it work with foobar which means it easier to find/populate/delete folders.

this file needs saving in your marc2003 folder: https://dl.dropboxusercontent.com/u/2280132...2003/common8.js
this needs to go in your panel. all previous preferences will be lost and you'll need to set them up again: https://dl.dropboxusercontent.com/u/2280132...emp/thumbs8.txt

if you have a big stash of artwork already saved in your wsh_lastfm folder, i've made a dirty script that will copy them into the new folder structure.

this will only work for artists in your library as i create an autoplaylist to get them all. you shouldn't even see the playlist as it gets created and then deleted automatically.

when done, a little report box should pop up telling you what it's done. there will be a new folder called wsh_data in your profile folder and inside that will be a folder named artists.

the script itself is a blank white panel and you double click to run. i have no idea how it works on large collections so you may want to backup your configuration first. it only copies files though - the originals will be left intact. download here: https://dl.dropboxusercontent.com/u/2280132...file%20copy.txt

WSH Panel Mod script discussion/help

Reply #3239
@marc2003

Tested it out as you requested and all works ok.
All Library artists artwork + musicbrainz.txt got imported to the new folder and panel works fine.

If I may submit some suggestions  since you are changing the script to wsh_data.

Make a folder structure like this to keep things tidy and separate.
wsh_data\artist\artwork
wsh_data\artist\musicbrainz
wsh_data\artist\lastfm

As to downloaded artists artwork  instead of those numeric ids from last.fm, maybe a filename scheme artist_1.png.

Modified Code:
Code: [Select]
	this.download = function() {
if (!this.folder.is_folder() || p.artist == "" || p.artist == "?") return;
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var folder = this.folder;


f = fso.GetFolder(folder);
fi = f.files.Count;
p.console("Files Count:" + fi);
f.Close;


var url = this.domain + "/music/" + encodeURIComponent(p.artist) + "/+images";
var func = function() {
var text = th.xmlhttp.responsetext;
doc.open();
var div = doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("img");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].src.indexOf("http://userserve-ak.last.fm/serve/126s") == 0) urls.push(data[i].src.replace("126s", th.download_size == th.download_sizes.small ? "252" : th.download_size == th.download_sizes.medium ? "500" : "_"));

}
for (i = 0; i < Math.min(urls.length, th.limit, 5); i++) {



p.console(urls[i]);
var index = i + 1;
p.console(index);
var increment = (fi + index);
p.console(increment);




p.run_cmd("cscript //nologo \"" + p.script_path + "download.vbs\" \"" + urls[i] + "\" \"" + folder + p.artist.validate() + "_" + increment + "." + urls[i].substring(urls[i].lastIndexOf(".") + 1) + "\"", false);



}
doc.close();
}
this.xmlhttp.open("GET", url, true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (th.xmlhttp.readyState == 4) {
if (th.xmlhttp.status == 200) {
func();
} else {
p.console("HTTP error: " + th.xmlhttp.status);
}
}
}
}



WSH Panel Mod script discussion/help

Reply #3240
The folder conversion script worked well for me. the foobar2000 display was nonresponsive while the conversion took place, but that was no big deal. I'll respect whatever you do marc2003, but a few thoughts:

1) Whatever character replacement you do, please either don't ever change it once you formally release the common8 approach, or please release another conversion script at the time of any character replacement change so that folder names can remain aligned with what common8 is doing with respect to character replacements.

2) While zeremy's suggestions might work for him and a few others, they will prevent me from ever adopting the common8 scripts and possibly others with many existing pictures. The redownloading of existing pictures and collisions with existing image names that will result from diverging from last.fm's image naming approach will be a pain with no benefit.  The folder location changes will trigger many personal script changes with no benefit, and also make the "open containing folder" command that much less useful.

3) Since you're making changes, it would be great if you could add the "open containing folder" option to at least the Musicbrainz, Last.fm Similar Artists, Allmusic review, and Last.fm & Wikipedia Biography scripts.

4) I would generally like to avoid downloading images when the artist is "Various Artists", "traditional", "anonymous" or similar artist strings that contain those characters. I currently mod your common7 to accomplish that, but it would be great if you could consider incorporating that in common8.

Thanks for your efforts!

WSH Panel Mod script discussion/help

Reply #3241
One other suggestion: I've found that eliminating concatenation of this.artist to the allmusic review search string in cases where this.artist = various artists results in far better album review search successes for VA albums. I don't know why, but it is consistently much better for just this specific case. I can't address that with just the artist tf, since if I pass a blank as the artist tf to the search, the search will find the correct review but store it in the artist folder of a blank instead of "various artists" as it should per what is my actual album artist. I currently accomplish what I want with a change to common 7 as follows, so please consider something similar for VA albums review searches:
Code: [Select]
            case "allmusic":
var temp_album = p.eval(this.allmusic_album_tf);
var temp_artist = p.eval(this.allmusic_artist_tf);
if (this.album == temp_album && this.artist == temp_artist) return false;
this.artist = temp_artist;
this.album = temp_album;
this.folder = p.data_folder + p.eval("$crc32(" + this.allmusic_artist_tf + ")");
if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
this.filename = this.folder + "\\Allmusic - " + p.clean_filename(this.album) + ".txt";
                fb.trace("filename sought equals  "+this.filename);
this.text = "Nothing found.";
if (p.fso.fileExists(this.filename)) {
this.text = p.open(this.filename);
} else {
                    if (this.artist == "Various Artists") {
                      this.allmusic_search = "http://www.allmusic.com/search/albums/" + encodeURIComponent(this.album);
                    } else {
  this.allmusic_search = "http://www.allmusic.com/search/albums/" + encodeURIComponent(this.album + " " + this.artist);
                    }
                    fb.trace("allmusic search string equals  "+this.allmusic_search);
this.allmusic_url = false;
this.get();
}

WSH Panel Mod script discussion/help

Reply #3242
but a few thoughts:


1) the illegal character replacement is actually done to match what the foobar core expects in the display preferences. if you use a a component like foo_facets or esplaylist to browse the artists in your library with artist art enabled, they should pick up all the artwork saved my script. simply configure the artist art in the core options with c:\path\to\wsh_data\artists\%artist%. if foobar changes the replacement in future, i guess i'd have to update to match it and make another conversion script for existing folders.

2) absolutely. the id from last.fm will always be kept as part of the filename. i always check the file exists locally and will skip trying to download it if it already does. changing this would indeed be useless and quite frankly, irresponsible.

3) i guess i could do that.

4) you can already do this with the artist field remapping option found on the right click menu. if the artist is of zero length (or a ?) then no lookup will even be attempted.

Code: [Select]
$if($or($stricmp(%artist%,traditional),$stricmp(%artist%,anonymous)),,%artist%)


i'll address the allmusic question later. i don't have time to read/digest it now.

@zeremy, i won't be considering subfolders because i just don't see any point. you are of course free to do what you like.

WSH Panel Mod script discussion/help

Reply #3243
@godrick, about allmusic various artists, i already discovered this myself back in may. 

http://www.hydrogenaud.io/forums/index.php...st&p=866515

as i could only verify the benefit on a single album, i just left it as it was. i'll definitely add it into the new script.

i'll probably upload a whole new pack of scripts over the weekend for testing. i'm sure there is something glaring in there that i will have missed.



WSH Panel Mod script discussion/help

Reply #3244
typo in post #3243 - i forgot to include filename wildcards in the path...

Quote
simply configure the artist art in the core options with c:\path\to\wsh_data\artists\%artist%\*.*

WSH Panel Mod script discussion/help

Reply #3245
I just discovered that about 33% of my images did not come over to the new directory, and about 22% of .txt files did not come over. I'm baffled as to why: the popup summary didn't show any failures or find any existing files (nor should it have). The reported tracks in my library was accurate, but the artist count is not the same as what foobar2000 reports. Yesterday I assumed that the artist count mismatch was a result of having artists with no images (of which I have many), but in looking at the script I think it should report the same number of artists as my facets column. I looked over the script and don't see anything that jumps out as a problem, keeping in mind I'm a script amateur.  Of the artists that are missing images and folders, the artist names do not have unusual characters, nor can I find any pattern to the misses. From what I can tell, the script seemed to skip an entire artist folder when it missed something, as opposed to just bringing over some of the images in an artist folder.

My gut tells me there is something different I need to do with the artist tf - I have lots of albums with multiple artists - but I'm not sure what else to try since $meta_branch(artist) and %<artist>% are both unrecognized by the script.

Suggestions appreciated!

WSH Panel Mod script discussion/help

Reply #3246
I just discovered that about 33% of my images did not come over to the new directory, and about 22% of .txt files did not come over. I'm baffled as to why: the popup summary didn't show any failures or find any existing files (nor should it have). The reported tracks in my library was accurate, but the artist count is not the same as what foobar2000 reports. Yesterday I assumed that the artist count mismatch was a result of having artists with no images (of which I have many), but in looking at the script I think it should report the same number of artists as my facets column. I looked over the script and don't see anything that jumps out as a problem, keeping in mind I'm a script amateur.  Of the artists that are missing images and folders, the artist names do not have unusual characters, nor can I find any pattern to the misses. From what I can tell, the script seemed to skip an entire artist folder when it missed something, as opposed to just bringing over some of the images in an artist folder.

My gut tells me there is something different I need to do with the artist tf - I have lots of albums with multiple artists - but I'm not sure what else to try since $meta_branch(artist) and %<artist>% are both unrecognized by the script.

Suggestions appreciated!

Here's a vbs script that will analyze any folder contents , and export it to a excel file.
You can run it on wsh_lastfm , and then on wsh_data and compare them (sort by size)  to  try to identify what is missed during the migration.

Save code as folder2excel.vbs

Code: [Select]
If (WScript.Arguments.Count <> 1) Then
WScript.Quit
End If

wsh_folder = WScript.Arguments(0)

Dim oFS, oFolder
Dim objExcel, r, lnameArray, lname, nameLength
set oFS = WScript.CreateObject("Scripting.FileSystemObject")
set oFolder = oFS.GetFolder(wsh_folder)

Set objExcel = createobject("Excel.application") 
objExcel.Visible = True
objExcel.Workbooks.add

'Sheet1
Set objWorksheet = objExcel.Worksheets("Sheet1")
objWorksheet.Activate
objWorksheet.Name = "Folder Sizes"

objExcel.Cells(1, 1).Value = "Folder Name"
objExcel.Cells(1, 2).Value = "Size (bytes)"
objExcel.Cells(1, 3).Value = "Size (KB)"
objExcel.Cells(1, 4).Value = "Size (MB)"
objExcel.Cells(1, 5).Value = "# Files"
objExcel.Cells(1, 6).Value = "# Sub Folders"
objExcel.Cells(1, 7).Value = "DateCreated"
objExcel.Cells(1, 8).Value = "Last Accessed"
objExcel.Cells(1, 9).Value = "Last Modified"
objExcel.Cells(1, 10).Value = "Path"

Set objRange = objExcel.Worksheets.Item(1).UsedRange
objRange.Font.Size = 12
objRange.Interior.ColorIndex = 36
objRange.Autofilter
Wscript.Sleep 300
r=2

ShowFolderDetails oFolder, r

objExcel.Columns(1).AutoFit()
objExcel.Columns(2).AutoFit()    
objExcel.Columns(3).AutoFit()
objExcel.Columns(4).AutoFit()
objExcel.Columns(5).AutoFit()
objExcel.Columns(6).AutoFit()
objExcel.Columns(7).AutoFit()
objExcel.Columns(8).AutoFit()
objExcel.Columns(9).AutoFit()
objExcel.Columns(10).AutoFit()

Set objRange2 = objExcel.Range("A1")
objRange2.Range("A2").Select
objExcel.ActiveWindow.FreezePanes = "True"

'Sheet2
Set objWorksheet = objExcel.Worksheets("Sheet2")
objWorksheet.Activate
objWorksheet.Name = "Files List"

objExcel.Cells(1, 1).Value = "File Name"
objExcel.Cells(1, 2).Value = "File Path"

Set objRange = objExcel.Worksheets.Item(2).UsedRange
objRange.Font.Size = 12
objRange.Interior.ColorIndex = 36
Wscript.Sleep 300
r=2

GetFiles(wsh_folder)

objExcel.Columns(1).AutoFit()
objExcel.Columns(2).AutoFit()

'Sheet3
Set objWorksheet = objExcel.Worksheets("Sheet3")
objWorksheet.Activate
objWorksheet.Delete


'Return to Sheet1
Set objWorksheet = objExcel.Worksheets("Folder Sizes")
objWorksheet.Activate



Function ShowFolderDetails(oF,r)
    Dim F
    objExcel.Cells(r, 1).Value = oF.Name
objExcel.Cells(r, 2).Value = oF.Size
objExcel.Cells(r, 3).Value = Round(oF.Size /1024)
objExcel.Cells(r, 4).Value = Round(((oF.Size /1024)/1024),2)
objExcel.Cells(r, 5).Value =  oF.Files.Count
objExcel.Cells(r, 6).Value =  oF.Subfolders.count
objExcel.Cells(r, 7).Value =  oF.DateCreated
    objExcel.Cells(r, 8).Value =  oF.DateLastAccessed
objExcel.Cells(r, 9).Value =  oF.DateLastModified
objExcel.Cells(r, 10).Value =  oF.Path
r = r+1
    for each F in oF.Subfolders
        ShowFolderDetails F, r
    next
End Function


Function GetFiles(FolderName)
On Error Resume Next

Dim ObjFolder
Dim ObjSubFolders
Dim ObjSubFolder
Dim ObjFiles
Dim ObjFile
Set ObjFolder = oFS.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files


For Each ObjFile In ObjFiles

objExcel.Cells(r, 1).Value = ObjFile.Name
objExcel.Cells(r, 2).Value = ObjFile.Path
r = r+1

Next

Set ObjSubFolders = ObjFolder.SubFolders

For Each ObjFolder In ObjSubFolders

GetFiles(ObjFolder.Path)

Next
End Function



From cmd line run: cscript //NOLOGO folder2excel.vbs "add_folder_path_here"



WSH Panel Mod script discussion/help

Reply #3247
The reported tracks in my library was accurate, but the artist count is not the same as what foobar2000 reports.


i don't have anyway to determine the artist from the old folder name which is why my script creates an autoplaylist of everything in your library. it then force sorts that playlist, loops through it and skips trying to do anything if the artist of the current track is the same as the previous. when a new artist is found, the counter increments by 1. i cannot explain why there would be any kind of mismatch here??

possible reasons for my script not detecting the old folders are as follows:

-you used artist field remapping on the old script. you can edit %artist% on line 1 to account for this. the default title formatting for the allmusic review script is actually %album artist% so that might account for a few folders. you'd have to edit the script and run it again.
-folders were created by the old script playing artists that are not in your library. this could include streams.
-the biggest flaw in my old script was that it was case sensitive....  if you've edited the artist tags during the use of the old script, new folders would have been created leaving the old ones obsolete.

Quote
I have lots of albums with multiple artists


albums are irrelevant. i'm only looking at the artist - or rather the title formatting defined on line 1.

all tracks in my library have a single value for the artist but i did a quick test with a multi value tag and it works as expected. i loaded up the old script, let it create the folder and dumped a load of files in it. the conversion script copied the files into a new folder where the artists were separated with a comma. however, the presence of multi value tags is unlikely to ever find anything online which is why i provided the artist field remapping option. you can use things like $meta(artist,0) to get the first value...

WSH Panel Mod script discussion/help

Reply #3248
Yup, that's what I'm doing right now - using the artist tf capability you created in the copy script so that I can iterate through the different multivalues using $meta(artist,n) and changing n with each run and then merging directories. I'm getting it done with little pain at this point - computer time is cheap!  Once I'm done with those, then dealing with any case-sensitive issues will be easy to deal with manually, so thanks for that tip.

WSH Panel Mod script discussion/help

Reply #3249
i've made a slightly more risky version of the copy script. only try this on a COPY of your wsh_lastfm folder.

this one actually deletes the original folders of any artists that exist in your library (after copying the files). when done, at least you may have a clearer idea of what to do with the remaining folders.

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