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

WSH Panel Mod script discussion/help

Reply #4251
zeremy, how do you get 2315402056 from http://89.16.185.174:8000/stream?

You can use any online hash conveter e.g http://aruljohn.com/hash.php

or this script to display it in window/console on playback.

Code: [Select]
// ==PREPROCESSOR==
// @name "crc32 path"
// @author "zeremy"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

// Use with GdiDrawText()
// {{
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
// }}

// {{
// Used in window.GetColorCUI()
ColorTypeCUI = {
    text: 0,
    selection_text: 1,
    inactive_selection_text: 2,
    background: 3,
    selection_background: 4,
    inactive_selection_background: 5,
    active_item_frame: 6
};

// Used in window.GetFontCUI()
FontTypeCUI = {
    items: 0,
    labels: 1
};

// Used in window.GetColorDUI()
ColorTypeDUI = {
    text: 0,
    background: 1,
    highlight: 2,
    selection: 3
};

// Used in window.GetFontDUI()
FontTypeDUI = {
    defaults: 0,
    tabs: 1,
    lists: 2,
    playlists: 3,
    statusbar: 4,
    console: 5
};
//}}

//{{
// Used in window.SetCursor()
var IDC_HAND = 32649;
//}}

var g_instancetype = window.InstanceType;
var g_font = null;
stream_id = "";
var ww = 0, wh = 0;
var g_textcolor = 0, g_textcolor_hl = 0;
var g_backcolor = 0;
var g_hot = false;

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

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

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

function on_paint(gr) {
    var text_color = g_hot ? g_textcolor_hl : g_textcolor;
    gr.GdiDrawText(stream_id, g_font, text_color, 0, 0, ww, wh, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
}

function on_mouse_lbtn_up(x, y) {
    window.ShowConfigure();
}

function on_mouse_move() {
    if (!g_hot) {
        window.SetCursor(IDC_HAND);
        g_hot = true;
        window.Repaint();
    }
}

function on_mouse_leave() {
    if (g_hot) {
        g_hot = false;
        window.Repaint();
    }
}

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

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




function get_stream_id(){
        metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
        stream_id = fb.TitleFormat("$crc32($lower(%path%))").EvalWithMetadb(metadb);
        fb.trace(stream_id);
    }
   
function on_playback_new_track(){
    get_stream_id();
    window.Repaint();
}

function on_playback_stop(){
    stream_id = "";
    window.Repaint();
}


WSH Panel Mod script discussion/help

Reply #4252
Thank you very much for your help.

I've changed my foobar setting according to your instruction.
And I found that the album art changes with differnet stations for the Marc2003's panel mod scripts in a separate panel.
But, the album art inside the JSPlaylist doesn't change. (It shows the default "nocover.png")

I've copy and paste the below scripts after deleting the original code.

I'm using "JSPlaylist v1.3.2 for my foobar.

When I'm listening to the streaming radio, it shows "stream.png".
I'd like to change "stream.png" according to the radio stations.

For example,
when I'm listening to "Linn" radio stations, I'd like to use "linn.png".
(Linn Radio Address : http://89.16.185.174:8000/stream)

Please, give me some hints.

To use stream logo's as artwork here is how I got it setup.

Create a folder stream-logo and rename the logo according to $crc32($lower(%path%))

e.g For http://89.16.185.174:8000/stream the filename is 2315402056.png



Setup Preferences > Display as below




For jsPlaylist to show the logo as the cover modify the script lines 708-722 as below.
Code: [Select]
//      if(track_type!=3) {
            if(metadb) {
                img = FormatCover(image, pw, ph, cover.draw_glass_reflect, false);
                if(!img) {
                    //img = (cGroup.type == 1) ? images.noartist : images.nocover;
                    img = null;
                    cover.type = 0;
                }; else {
                    cover.type = 1;
                };
            };
//      }; else {
//          img = images.stream;
//            cover.type = 3;
//        };

WSH Panel Mod script discussion/help

Reply #4253
The image is the group header which shows nocover.png.

You have to change the.group settings  (right click column headers > edit groups )

or disable groups (right click column headers > Groups > disable Enable Groups).

Also in columns enable cover to be visible.


WSH Panel Mod script discussion/help

Reply #4254
The image is the group header which shows nocover.png.

You have to change the.group settings  (right click column headers > edit groups )

or disable groups (right click column headers > Groups > disable Enable Groups).

Also in columns enable cover to be visible.


Here I attached the the difference between the original and modified scripts.

Original


Modified


The group header image has been changed from "stream.png" to "nocover.png".
I want to the header image is changing to "radio station images."
I tried to find if there is any lines where I can change to show up the radio station miage in "group header", but I couldn't.

Please, let me know if there is anything I'm missing.

Thank you again for your help.
//
I've found that the group header image was fixed according to the first track list within the playlist.
So, after I move the second radio station to the first palce, the linn radio station image show up properly.
I guess that it would be so difficult to change the group header image with changing radio stations.

Anyway, thanks for your help and good scripts.

WSH Panel Mod script discussion/help

Reply #4255
If you are using the default group pattern Album Artist | Album | Disc
change Title Format to
$if(%album artist%,%album artist%,%path%)album%%discnumber%

Disable cover in columns.

It should now show up as you like.


WSH Panel Mod script discussion/help

Reply #4256
If you are using the default group pattern Album Artist | Album | Disc
change Title Format to
$if(%album artist%,%album artist%,%path%)album%%discnumber%

Disable cover in columns.

It should now show up as you like.


Wow!!!
Thank you very much.
It's exactly what I wanted.

WSH Panel Mod script discussion/help

Reply #4257
First of I want to say thanks to Marc2003 for his scripts.

I have been trying to mod his Last.fm bio script, the key word is trying since I have not advanced in my quest. What I been wanting to achieve is to add a case to fetch the album info from last.fm instead of artist info. I thought this would be easy since only the difference in the url from artist is a "/album", however I have had no luck with it so I turn over here to see if I can get some help to do it.

What I have done so far is to see on the allmusic case (since it seem it take into account the album) and lastfm_bio case. I have only changed stuff under lastfm_bio case in the text.js file.

Here is what I have done so far (if it is not okay to post the code just say so and I will edit it away):

Code: [Select]
				
case "lastfm_bio_album":
var temp_artist = panel.tf(panel.artist_tf);
var temp_album = panel.tf(panel.album_tf); //added this line
if (this.artist == temp_artist && this.album == temp_album) // added the && this.album == temp_album part
return;
this.artist = temp_artist;
this.album = temp_album;  //added this line
this.content = "";
this.filename = panel.new_artist_folder(this.artist) + "bio_linje67." + this.bio_lastfm_sites[this.bio_lastfm_site] + ".json";  // seems like it is this line that determine the filename that is saved, but I cant figure out how to save it as the album (have tried the _.fbSanitise(this.album) from allmusic case but have not worked so far
if (_.isFile(this.filename)) {
var data = _.jsonParse(_.open(this.filename));
this.content = data[0];
if (_.fileExpired(this.filename, ONE_DAY))
this.get();
} else {
this.get();
}
break;

Have showed what I have changed. The other part that I have changed is this, which seems is what that types in the url

Code: [Select]
	case "lastfm_bio_album":
if (!_.tagged(this.artist))
return;
var url = "http://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/" + encodeURIComponent(this.album) + "/+wiki";
break;

I have tried to add the  || !_.tagged(this.album) in the if statement, but then it seems it do not fetch anything. It still fetches the artist bio even though the url should get the album info, that is if I understand this correct.

If some could help that would be awesome

WSH Panel Mod script discussion/help

Reply #4258
Can't find a edit so it will be a double post.

Woohoo, I managed to trick it together  The problem was that the this.album was not defined for the lastfm case. Here is my solution if anyone else want to use it.

Under this.metadb_changed = function () change the following things:

            case "lastfm_bio_album":
               var temp_artist = panel.tf(panel.artist_tf);
               var temp_album = panel.tf(this.allmusic_album_tf);
               if (this.artist == temp_artist && this.album == temp_album)
                  return;
               this.artist = temp_artist;
               this.album = temp_album;
               this.content = "";
               this.filename = panel.new_artist_folder(this.artist) + "album." + _.fbSanitise(this.album) +"." + this.bio_lastfm_sites[this.bio_lastfm_site] + ".json";
               if (_.isFile(this.filename)) {
                  var data = _.jsonParse(_.open(this.filename));
                  this.content = data[0];
                  if (_.fileExpired(this.filename, ONE_DAY))
                     this.get();
               } else {
                  this.get();
               }

Under this.get = function ()
         case "lastfm_bio_album":
            if (!_.tagged(this.artist) || !_.tagged(this.album))
               return;
            var url = "http://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/" + encodeURIComponent(this.album) + "/+wiki";
            break;

Under this.success = function (f)
I just added a            this.album = "";

Under this.header_text = function ()
         case "lastfm_bio_album":
            return panel.tf("%album artist%[ - %album%]");
            break;

And finally under this.init = function () I added          this.allmusic_album_tf = window.GetProperty("2K3.TEXT.ALLMUSIC.ALBUM.TF", "%album%");


Probably a waste of time writing this to the pro people here but maybe another noob like me is after something like this and can find use in it. The way I did this was to copy all the instances of the case lastfm_bio and made a new case called lastfm_bio_album. The only code that is changed is listed above, the rest of the cases is just a copy. When the script is loaded to get the album info change line 13 from that says lastfm_bio into lastfm_bio_album. I also made a new copy of the text.js file and made the changes the new file which I called textmod.js and changed line 9 to read \textmod.js.


WSH Panel Mod script discussion/help

Reply #4259
New day and a new question. Is it possible to add buttons inside WSH mod? Instead of right clicking to choose what to see I want buttons to click on, for example news/blogs/reviews you right click to choose which one to display, is it possible to make some textboxes and click on those to choose what to display.


(Hope this make sense, if not just say so and I will try to explain myself better)

WSH Panel Mod script discussion/help

Reply #4260
New day and a new question. Is it possible to add buttons inside WSH mod? Instead of right clicking to choose what to see I want buttons to click on, for example news/blogs/reviews you right click to choose which one to display, is it possible to make some textboxes and click on those to choose what to display.


(Hope this make sense, if not just say so and I will try to explain myself better)

see this But it's for changing mode in last fm and it's for marc's previous script ( common8 )
as i haven't figured out the new scripts  i don't know the exact lines 
so lines like
li.lastfm_change_mode
this.lastfm_mode = m
have to be changed accordingly
hope you'll figure it out

WSH Panel Mod script discussion/help

Reply #4261
Is that code added in the text file or the .js file?

WSH Panel Mod script discussion/help

Reply #4262
Is that code added in the text file or the .js file?
In text file .You should probably make copy of it first
Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Artist Info/User Charts/Recommendations"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// @import "%fb2k_profile_path%wsh_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\panel.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\lastfm.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\list.js"
// ==/PREPROCESSOR==

var panel = new _.panel("Last.fm Artist Info/User Charts/Recommendations", ["metadb", "custom_font"]);
var lastfm = new _.lastfm();
//lastfm.api_key = "abc123"; //uncomment these 2 lines
//lastfm.secret = "abc123"; //and edit accordingly
var list = new _.list("lastfm_info", 10, 30, 0, 0);
var bs = 32;
var buttons = new _.buttons();
list.lastfm_change_mode = function (m) {
    this.lastfm_artist_method = m;
    window.SetProperty("2k3.lastfm_mode", this.lastfm_mode); //store the value so it's remembered on panel reload/foobar restart
    this.artist = ""; //the panel won't update if the artist doesn't change so i just clear it
    panel.item_focus_change(); //this calls the function that refreshes the panel - don't repaint because it's already done for you
}



buttons.buttons.sartist = new _.button(0, 20, bs, bs, {normal : "buttons\\sartist.png"}, function () {list.lastfm_change_mode(1);} , "similer artist");
buttons.buttons.tags = new _.button(bs, 20, bs, bs, {normal : "buttons\\tags.png"}, function () { list.lastfm_change_mode(2); }, "top tags");
buttons.buttons.talbum = new _.button(bs * 2, 20, bs, bs, {normal : "buttons\\talbum.png"}, function () { list.lastfm_change_mode(3); }, "top albums");
buttons.buttons.top = new _.button(bs * 3, 20, bs, bs, {normal : "buttons\\top.png"}, function () { list.lastfm_change_mode(4);}, "top tracks");




panel.item_focus_change();

function on_notify_data(name, data) {
lastfm.notify_data(name, data);
}

function on_size() {
panel.size();
list.w = panel.w - 20;
list.h = panel.h - 24;
list.size();
}

function on_paint(gr) {
panel.paint(gr);
gr.FillSolidRect(0, 0, panel.w, 24, panel.colours.header);
gr.GdiDrawText(list.header_text(), panel.fonts.title, panel.colours.highlight, 10, 0, panel.w - 20, 24, LEFT);
list.paint(gr);
        buttons.paint(gr);
}

function on_metadb_changed() {
list.metadb_changed();
}

function on_mouse_wheel(s) {
list.wheel(s);
}

function on_mouse_move(x, y) {
list.move(x, y);
        buttons.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
list.lbtn_up(x, y);
        buttons.lbtn_up(x, y);
}

function on_key_down(k) {
list.key_down(k);
}

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y, list);
}
and you should edit 29-32 lines to relevent image names(buttons\\sartist.png) and put relevant png buttons in wsh_marc2003\images\buttons folder  named  accordingly

WSH Panel Mod script discussion/help

Reply #4263
  Duplicate

WSH Panel Mod script discussion/help

Reply #4264
Awesome  I should manage to get what I want from this. I know I'm asking a lot of questions here, but is it possible to make a text button similar to  Panel Stack Splitter buttons? That change color based on if I hover the mouse over it and whether it is active. The code that I use in PSS is as following:
$textbutton(271,0,80,23,Last.fm,Last.fm,SETGLOBAL:mainpanel:5;REFRESH,fontcolor:255-255-255 brushcolor:$get(LastButton),fontcolor:255-255-255 brushcolor:0-255-0)
$textbutton(x,y,w,h,text,mover_text,command,options1,options2)

WSH Panel Mod script discussion/help

Reply #4265
You could refer to examples provided with the component
see foobar2000\user-components\foo_uie_wsh_panel_mod\samples\SimpleThemedButton
and refer what's in docs folder

WSH Panel Mod script discussion/help

Reply #4266
Ok  Thanks for the help


WSH Panel Mod script discussion/help

Reply #4268
Quote
Playcount sync is not included.

 

But let's not get greedy. Thanks for making these available!

WSH Panel Mod script discussion/help

Reply #4269
Thanks marc2003, you know what append to your now.playing.txt ???
thanks 

WSH Panel Mod script discussion/help

Reply #4270
I have problem with this script, script works fine after second attempt.
If i click apply-ok in properties, script wont work on first time, but works fine after that.
What's the problem?

Code: [Select]
GET_ART = function()
{
url = "https://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&artist=" + encodeURIComponent(Artist) + "&api_key=" + api + "&format=json&limit=" + art;

xmlhttp.open("GET",url,true);
xmlhttp.send();

xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            
data = xmlhttp.ResponseText;

try {
json_data = JSON.parse(data);

//Check length
ln = json_data.similarartists.artist;
ln = ln.length;
//fb.trace('similar(length): '+ln);

//Select random artist
randomnumber = Math.floor(Math.random()*(1-ln)+ln);
var i = randomnumber;

ar = json_data.similarartists.artist[i].name.replace(/&/g, " \& ");
fb.trace(ar);

//Save
if (ar > "")
{
SIM_ART = window.SetProperty("Similar", ar);
SIM_ART = ar;
window.SetProperty("Similar", ar);
}
else
{
SIM_ART = window.SetProperty("Similar", "");
SIM_ART = "";
window.SetProperty("Similar", "");
}                  

xmlhttp.close;
        
} catch (err) {
            xmlhttp.close;
        }        
    
} else
        if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
              
}}
}

 

WSH Panel Mod script discussion/help

Reply #4271
I have problem with this script, script works fine after second attempt.
If i click apply-ok in properties, script wont work on first time, but works fine after that.
What's the problem?

Code: [Select]
GET_ART = function()
{
url = "https://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&artist=" + encodeURIComponent(Artist) + "&api_key=" + api + "&format=json&limit=" + art;

xmlhttp.open("GET",url,true);
xmlhttp.send();

xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            
data = xmlhttp.ResponseText;

try {
json_data = JSON.parse(data);

//Check length
ln = json_data.similarartists.artist;
ln = ln.length;
//fb.trace('similar(length): '+ln);

//Select random artist
randomnumber = Math.floor(Math.random()*(1-ln)+ln);
var i = randomnumber;

ar = json_data.similarartists.artist[i].name.replace(/&/g, " \& ");
fb.trace(ar);

//Save
if (ar > "")
{
SIM_ART = window.SetProperty("Similar", ar);
SIM_ART = ar;
window.SetProperty("Similar", ar);
}
else
{
SIM_ART = window.SetProperty("Similar", "");
SIM_ART = "";
window.SetProperty("Similar", "");
}                  

xmlhttp.close;
        
} catch (err) {
            xmlhttp.close;
        }        
    
} else
        if (xmlhttp.status == 404) {p.console("HTTP error: " + xmlhttp.status);}
              
}}
}

I had the same problem.
Try sending the request xmlhttp.send(); after the xmlhttp.onreadystatechange = function()

Code: [Select]
GET_ART = function () {
url = "https://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&artist=" + encodeURIComponent(Artist) + "&api_key=" + api + "&format=json&limit=" + art;

xmlhttp.open("GET", url, true);


xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {

data = xmlhttp.ResponseText;

try {
json_data = JSON.parse(data);

//Check length
ln = json_data.similarartists.artist;
ln = ln.length;
//fb.trace('similar(length): '+ln);

//Select random artist
randomnumber = Math.floor(Math.random() * (1 - ln) + ln);
var i = randomnumber;

ar = json_data.similarartists.artist[i].name.replace(/&/g, " \& ");
fb.trace(ar);

//Save
if (ar > "") {
SIM_ART = window.SetProperty("Similar", ar);
SIM_ART = ar;
window.SetProperty("Similar", ar);
} else {
SIM_ART = window.SetProperty("Similar", "");
SIM_ART = "";
window.SetProperty("Similar", "");
}

xmlhttp.close;

} catch (err) {
xmlhttp.close;
}

} else
if (xmlhttp.status == 404) {
p.console("HTTP error: " + xmlhttp.status);
}

}
}
xmlhttp.send();
}

WSH Panel Mod script discussion/help

Reply #4272
what the f...lip. my code has been like this since 2009 and it has always been 100% reliable...

Code: [Select]
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("User-Agent", user_agent);
xmlhttp.send();
xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            //success
        } else {
            //fail
        }
    }
}

WSH Panel Mod script discussion/help

Reply #4273
what the f...lip. my code has been like this since 2009 and it has always been 100% reliable...

Code: [Select]
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("User-Agent", user_agent);
xmlhttp.send();
xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            //success
        } else {
            //fail
        }
    }
}


This is an observation that I made trying to make other scripts work.
I know your code works in your scripts, but this "hack" works for me..
I think it has to do with the fact that the function is not defined already when the send (null) request is triggered.

WSH Panel Mod script discussion/help

Reply #4274
I had the same problem.
Try sending the request xmlhttp.send(); after the xmlhttp.onreadystatechange = function()

Code: [Select]
GET_ART = function () {
url = "https://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&artist=" + encodeURIComponent(Artist) + "&api_key=" + api + "&format=json&limit=" + art;

xmlhttp.open("GET", url, true);


xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {

data = xmlhttp.ResponseText;

try {
json_data = JSON.parse(data);

//Check length
ln = json_data.similarartists.artist;
ln = ln.length;
//fb.trace('similar(length): '+ln);

//Select random artist
randomnumber = Math.floor(Math.random() * (1 - ln) + ln);
var i = randomnumber;

ar = json_data.similarartists.artist[i].name.replace(/&/g, " \& ");
fb.trace(ar);

//Save
if (ar > "") {
SIM_ART = window.SetProperty("Similar", ar);
SIM_ART = ar;
window.SetProperty("Similar", ar);
} else {
SIM_ART = window.SetProperty("Similar", "");
SIM_ART = "";
window.SetProperty("Similar", "");
}

xmlhttp.close;

} catch (err) {
xmlhttp.close;
}

} else
if (xmlhttp.status == 404) {
p.console("HTTP error: " + xmlhttp.status);
}

}
}
xmlhttp.send();
}

This works O.o

I looked on response if i send  request ''xmlhttp.send();'' before the ''xmlhttp.onreadystatechange = function() '' i receive:

1
1
1
2
3
4

And when it reaches 4, it won't pass..