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

WSH Panel Mod script discussion/help

Reply #2950
You can do it with regex, for example:
Code: [Select]
var url = "about:/watch?v=26PAgklYYvo"
url = url.replace(/about:\//,"")
fb.trace(url)

Yes, in your example this will work..
But i must use something like this(Because i don't know what will come after "about:/''):

Code: [Select]
var url = data[i];

var url = url.replace('about:/','/');

//open YT in playlist
var tmppath = p.fso.GetFolder(fb.FoobarPath).ShortPath;
p.run(tmppath+"\\foobar2000.exe /immediate /add "+"\""+"http://www.youtube.com"+ url + "\"");

Output now should be : ''http://www.youtube.com/watch?v=26PAgklYYvo''
But i recieve error: ''Object doesn't support this property or method''

Problem is that actualy ''data'' is 'html element tag'(if u see script above) not string.
So this didn't work for me..


Quote
this.xmlhttp.open("GET", "http://www.youtube.com/watch?v=I7HahVwYpwo" + encodeURIComponent(p.artist) + "/+images", true);

that part in bold is left behind from the last.fm script and should be removed. 

I was removed this, i use your script at the begining(to not write all), i learned a lot from from you  .
Do you know how to remove this: "about:/'' from url?

WSH Panel Mod script discussion/help

Reply #2951
i don't know what you're doing with this???

for (i = 33; i < data.length; i++)
{
   if (data.href.indexOf("/watch?v=") == 0) urls.push(data.href.replace("", ""));
}


what you want to do is loop through all of them and just keep the ones that begin about:/watch?v=

Code: [Select]
for (i = 0; i < data.length; i++) {
    if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
}


now urls is an array containing only links to playable videos.

Code: [Select]
for (i = 0; i < urls.length; i++) {
    //do something with urls[i]
}





WSH Panel Mod script discussion/help

Reply #2952
i don't know what you're doing with this???

for (i = 33; i < data.length; i++)
{
   if (data.href.indexOf("/watch?v=") == 0) urls.push(data.href.replace("", ""));
}


what you want to do is loop through all of them and just keep the ones that begin about:/watch?v=

Code: [Select]
for (i = 0; i < data.length; i++) {
    if (data[i].href.indexOf("about:/watch?v=") == 0) urls.push("http://www.youtube.com/" + data[i].href.replace(/about:\//,""));
}


now urls is an array containing only links to playable videos.

Code: [Select]
for (i = 0; i < urls.length; i++) {
    //do something with urls[i]
}



Ah, Marc your the best, as always, it works
I was think that i keep only that one clip at end: on every played clip in foobar, it (recieve url where clip is) open new clip from that page(last clip), and so on... Trying to make some sistem recomendation, and that same clips are not be repeated..


WSH Panel Mod script discussion/help

Reply #2953
Hello,

Can I somehow bind a shortcut (e.g CTR+1) to a button created via WSH Panel Mod and Marc's WebLinks script? (My code)

WSH Panel Mod script discussion/help

Reply #2954
you can get WSH panel mod to accept keyboard input but foobar must have focus and the WSH panel must be the last thing you clicked so it's not particular useful if you want to make keyboard shortcuts. you can't make them "global".

if you want to try it anyway, here is a bit of code to get you started....

Code: [Select]
function on_key_down(vkey) {
    //p.console(vkey); //uncomment this to get the code of the button you've pressed. it's used in the switch statement below.
    if (p.metadb && utils.IsKeyPressed(0x11)) { //check something is selected and ctrl is held
        switch(vkey) {
            case 49: //1
                b.buttons.google.func();
                break;
            case 50: //2
                b.buttons.myspace.func();
                break;
        }
    }
}



WSH Panel Mod script discussion/help

Reply #2955
Is it possible to script WSH so it mimics the functions of the DUI 'Tabs' feature? I've tried to google-fu an answer but that one has proven to be elusive when DUI is the main interface.

WSH Panel Mod script discussion/help

Reply #2956
marc2003, big thank you for the samples. I use almost all of them.

I have one suggestion for "musicbrains" script. Can you add an option to choose sorting order for releases: chronological or reversed.
or at least tell me how to change that myself. (btw I did search this topic and previous solution seems not to work any more)

WSH Panel Mod script discussion/help

Reply #2957
Is it possible to script WSH so it mimics the functions of the DUI 'Tabs' feature? I've tried to google-fu an answer but that one has proven to be elusive when DUI is the main interface.


if you want to show/hide other panels then no. if you want to show some "tabs" for stylistic purposes to show/hide content in a single WSH panel then you can use the thememanager functions described in interfaces.txt and this online documentation: http://msdn.microsoft.com/en-us/library/bb...28VS.85%29.aspx

Can you add an option to choose sorting order for releases: chronological or reversed.


i've added an option to the right click menu so this can be toggled. reverse is still the default though. i've added this to my discogs script as well as they share the same sorting functions.

right click>Update script

full download: https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip
changelog: https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt

WSH Panel Mod script discussion/help

Reply #2958
marc, thank you for update.

I found issue in musicbrains script. It works well with all artists in my library (which is big) except "AC/DC" and "Guns N' Roses". Other scripts works ok with them. I think it may be because of / and ' symbols in artist's name but its just a guess

my english probably bad, sorry

WSH Panel Mod script discussion/help

Reply #2959
in their editing guidelines, musicbrainz don't like people using the apostrophe on their keyboard. they prefer the "typographically" correct character which is this ’

that's why my script didn't match any results. i might be able to work around this.

as for AC/DC, they aren't even accepting that as a search parameter. i'm doing things right so i think it's a problem their end. it's something i'll have to look in to.

you can of course get around any of these tagging issues if your files are tagged with musicbrainz_artistid as my script will look up those directly without doing an artist search.

this is the id for Guns n' Roses... eeb1195b-f213-4ce1-b28c-8565211f8e43
and AC/DC... 66c662b6-6e2f-4930-8610-912e24c63ed1

also, just in case you hadn't realised, you can turn off the Show timestamp option so the text doesn't go over the arrow at the bottom. i guess it's only usable on wider panels.

WSH Panel Mod script discussion/help

Reply #2960
i've updated the musicbrainz script so the type of apostrophe doesn't matter any more.

right click>Update script.

edit: updated so AC/DC should work as well. i still think the problem is at musicbrainz's end but i'm working around it.

WSH Panel Mod script discussion/help

Reply #2961
another little update for my musicbrainz script. right click to update.

a few bugfixes and i also worked around a few more characters that were previously refused by the musicbrainz search server.

WSH Panel Mod script discussion/help

Reply #2962
Can someone get me started on a script that rates the currently playing track? I can't figure how to make use of the many "meta" methods.

WSH Panel Mod script discussion/help

Reply #2963
first you need the handle of the now playing track and then you use UpdateFileInfoSimple with the tag name and value like this...

Code: [Select]
var metadb = fb.GetNowPlaying();
metadb.UpdateFileInfoSimple("RATING", 5);


if you want to delete a tag, just use double quotes...

Code: [Select]
metadb.UpdateFileInfoSimple("RATING", "");


i actually have a full rating script already if you want to take a look.

https://dl.dropboxusercontent.com/u/2280132...om%20rating.txt

these are the images i use.



you might need to look at editing the paths to the images on lines 102 & 103. also, the number 24 on line 11 is the image size so might need changing if you use your own images.

WSH Panel Mod script discussion/help

Reply #2964
Thanks for the response.

I'm actually hoping to get my script to complement PlaybackStatistics. It took me some time to realize that it doesn't actually write metadata.

Is it at all possible to outsource a query to foobar, as in "%RATING%"? I'm also unclear as to the usage of RunContextCommand, if that's even helpful here.

Sorry if I'm a bit of a bother. I'm not a programmer first.

WSH Panel Mod script discussion/help

Reply #2965
in that case, just download this pack of scripts i made.

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

you'll want the script named rating.txt - this is already made to work with foo_playcount. just read the instructions. you don't need to edit the script at all.

if you don't like the bundled images, i can tell you how to modify the code to use your own.

WSH Panel Mod script discussion/help

Reply #2966
Thank you for creating amazing components and scripts for fb2k. Life wouldn't be the same without them, i'm not kidding.

Is there any way to add/append "scrobbles" and "listeners" (to artists, albums etc.) in your last.fm script?

WSH Panel Mod script discussion/help

Reply #2967
i only make crappy scripts. i certainly didn't have anything to do with creating the component.

anyway, i had a look at the data i can get from last.fm and it's a bit odd. only the toptracks and topalbums feeds return playcounts but they don't seem to correlate with anything on the website. for example, i see the top track for who i'm listening to has 59,000 plays. i thought this was far too low so checked the website and it has  ~1.9 million. the only other playcounts i can see are for the last week (1438) and the last 6 months (21,600). i have no idea where the 59,000 is coming from so i think it's a bit pointless showing it. obviously i double checked the raw data from last.fm so my script is not at fault.

edit: if you want to see for yourself, you can add this code to the panel. on line 30, you find this....

Code: [Select]
        case li.items > 0:
            li.draw(gr);
            break;


replace it with...

Code: [Select]
        case li.items > 0:
            li.draw(gr);
            if (li.lastfm_mode > 2) {
                for (i = 0; i < Math.min(li.items, li.rows); i++) {
                    p.right_text(gr, li.data[i + li.offset].playcount.addCommas() + " plays", p.list_font, p.textcolour_hl, li.x, li.y + 15 + (i * li.row_height), li.w, li.row_height);
                }
            }
            break;

WSH Panel Mod script discussion/help

Reply #2968
i only make crappy scripts. i certainly didn't have anything to do with creating the component.


Even so, I can't sing enough praises for your scripts.

Quote
anyway, i had a look at the data i can get from last.fm and it's a bit odd. only the toptracks and topalbums feeds return playcounts but they don't seem to correlate with anything on the website. for example, i see the top track for who i'm listening to has 59,000 plays. i thought this was far too low so checked the website and it has  ~1.9 million. the only other playcounts i can see are for the last week (1438) and the last 6 months (21,600). i have no idea where the 59,000 is coming from so i think it's a bit pointless showing it. obviously i double checked the raw data from last.fm so my script is not at fault.

edit: if you want to see for yourself, you can add this code to the panel. on line 30, you find this....

Code: [Select]
        case li.items > 0:
            li.draw(gr);
            break;


replace it with...

Code: [Select]
        case li.items > 0:
            li.draw(gr);
            if (li.lastfm_mode > 2) {
                for (i = 0; i < Math.min(li.items, li.rows); i++) {
                    p.right_text(gr, li.data[i + li.offset].playcount.addCommas() + " plays", p.list_font, p.textcolour_hl, li.x, li.y + 15 + (i * li.row_height), li.w, li.row_height);
                }
            }
            break;


I modified the script. I checked the playcounts and found the count reported by the script in most cases are just over double that of the playcount number for 6 months. So I am guessing it could be for 1 year?

Anyway, playcounts for individual tracks are not really important for me. What I am interested in is getting "scrobbles" for  artists and "listeners" for artists and albums.

For e.g. Björk has total of 87,901,733 scrobbles 1,957,941  listeners. and the following top albums:

Homogenic: 455,342 listeners
Post: 644,504 listeners
Debut: 534,509 listeners
Vespertine: 309,415 listeners

I update them to the tags for use while sorting in the library. Presently I am doing it manually by visiting the artist page on last.fm periodically. Of course I use your web-links to visit the page which makes it a bit easier than usual, but it would be great if I could get the data on panel.

Thank your for the quick reply.




WSH Panel Mod script discussion/help

Reply #2969
if you use my last.fm album info panel, this can display total listeners/playcount for the current album.

add this as the last line inside the on_paint function - it should end up on line 28...

Code: [Select]
if (t.json_data && t.json_data.album) p.left_text(gr, t.json_data.album.listeners.addCommas() + " listeners. " + t.json_data.album.playcount.addCommas() + " plays.", p.list_font, p.textcolour_hl, t.x, t.y + t.h - 15, t.w, 15);


edit:


For e.g. Björk has total of 87,901,733 scrobbles 1,957,941  listeners. and the following top albums:

Homogenic: 455,342 listeners
Post: 644,504 listeners
Debut: 534,509 listeners
Vespertine: 309,415 listeners


this is clealy nonsense. vespertine is by far her best album. 

WSH Panel Mod script discussion/help

Reply #2970
if you use my last.fm album info panel, this can display total listeners/playcount for the current album.

add this as the last line inside the on_paint function - it should end up on line 28...

Code: [Select]
if (t.json_data && t.json_data.album) p.left_text(gr, t.json_data.album.listeners.addCommas() + " listeners. " + t.json_data.album.playcount.addCommas() + " plays.", p.list_font, p.textcolour_hl, t.x, t.y + t.h - 15, t.w, 15);


edit:


For e.g. Björk has total of 87,901,733 scrobbles 1,957,941  listeners. and the following top albums:

Homogenic: 455,342 listeners
Post: 644,504 listeners
Debut: 534,509 listeners
Vespertine: 309,415 listeners


this is clealy nonsense. vespertine is by far her best album. 



Done. Works fine. I find the previous track playcount useful too. I checked a few more tracks, the sorting order is for "last week". Sorting order going by the playcount would be quite different, and hence more and more seems to me to be for 1 year. I find it useful nevertheless.

So no chance to add "scrobbles" and "listeners" to artists/albums which can be be displayed in "top albums" and "similar artists" panel?. Will make discovering new music easier. Maybe I am being a bit too greedy here. . Your scripts as it is, are doing quite enough.

RYM ratings are more reliable/meaningful. Some artists who are very popular on last.fm have hardly a standing there. Unfortunately there is no API for it. I have added RYM button to your web-links script

Thanks for everything.

WSH Panel Mod script discussion/help

Reply #2971
So no chance to add "scrobbles" and "listeners" to artists/albums which can be be displayed in "top albums" and "similar artists" panel?


nope. the information simply is not there....


WSH Panel Mod script discussion/help

Reply #2972
So no chance to add "scrobbles" and "listeners" to artists/albums which can be be displayed in "top albums" and "similar artists" panel?


nope. the information simply is not there....





A couple of years back I had come across a Audio player (I can't seem to remember now which one) based on last.fm API, which used to display the data which I am referring to. It was some player which was listed on the last.fm website. I naturally assumed it would be possible to fetch the data using your script.

I just now tried Clementine, unlike the playcount we are getting from the script, it correctly reports the "scrobbles" and "listeners" for the track which is found on the song page. I will try to find out the name of the other audio player.

Sorry for putting you through so much of trouble.

Thanks again.


WSH Panel Mod script discussion/help

Reply #2973
You are right. I checked the last.fm site. There is no provision in API to fetch that data, at least in the way I mentioned. Perhaps the other player which I referred to uses a HTML parser.

I do not know how to write scripts. So I have some requests.

(1) Would it possible to put the "artist.getInfo" (it contains similar artists info too) data in a panel. Perhaps in the following format in a single panel. I can use it in lieu of "similar artists" panel. Also, this way I will have a clickable link to the artist page (currently I am using web-link button). This would save me some visits to the last.fm site. I think it also has a similarity match percentage. Would be great if that too could be added.

[blockquote]artist info
Name: Cher
Listeners : 1,000,000
Plays: 10,000,000

Similar artists:
Sonny & Cher
Kylie Minogue
Madonna
RuPaul
Céline Dion
Cyndi Lauper[/blockquote]


(2) 'artist.getTopAlbums' has got "listeners" info. Would it be possible to add that data to the "top albums" panel?. Just like you added the playcount to "top tracks" panel.

(3) Panel for similar tracks using 'track.getSimilar'.


All in your own time......no rush.....at all. 

Hope I am not imposing.

Thanks.

WSH Panel Mod script discussion/help

Reply #2974
i generally only make stuff i'm interested in using myself and i'm just not interested in this. i don't mind helping out with a few lines of code to mod existing scripts but i'm not making any new ones.

as for point 2, you're wrong. top album does not contain listener info - only top tracks does.