Re: [SlimDevices: Plugins] Spotty and JSON RPC vs CLI
I've written a control interface in Pascal (Free Pascal) to control my Ok, no Perl needed then. I don't see where exactly you're facing issues. But make sure to instead of asking LMS for a URL, you use your query with "item_id:123", putting the ID from the element you want to navigate. That's working fine here. -- Michael ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins
Re: [SlimDevices: Plugins] Spotty and JSON RPC vs CLI
I've written a control interface in Pascal (Free Pascal) to control my home. Part of that is as interface to LMS that lets me select and schedule music. It uses HTTP POST commands to the jsonprc.js page in LMS to browse the server and control things (like add something to the queue). Unfortunately I'm not a Perl expert, but up until now, I thought I had a good handle on the jsonrpc.js interface. It seems like it can't actually handle the JSON being generated by the Spotty plugin when an item type is "playlist" because the url is not something the "to_json" function likes, maybe?. I'm not sure. I'm also not sure I'm on the latest LMS so that's my next step... to get that updated and see if it makes a difference. littla's Profile: http://forums.slimdevices.com/member.php?userid=63581 View this thread: http://forums.slimdevices.com/showthread.php?t=112794 ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins
Re: [SlimDevices: Plugins] Spotty and JSON RPC vs CLI
Around line 281 the JSON response to be returned looks like this: I think you should describe what you're trying to do in more detail. Are you implementing your own client in Perl? -- Michael ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins
Re: [SlimDevices: Plugins] Spotty and JSON RPC vs CLI
Thanks karlek, I saw the error in the code I copied in and was editing it when I saw your post. I've corrected the original post now, but the code was not the issue. I'm trying what you said, and have the jsonrpc on debug level logging. Around line 281 the JSON response to be returned looks like this: { id => 53, method => "slim.request", params => ["98:fe:95:00:00:00", ["spotty", "items", 0, 8, "want_url:1"]], result => { # tied Tie::IxHash count => 8, loop_loop => [ { # tied Tie::IxHash hasitems => 1, id => 0, image => "plugins/Spotty/html/images/search.png", isaudio => 0, name => "Search", type => "search", }, { # tied Tie::IxHash hasitems => 1, id => 1, image => "plugins/Spotty/html/images/whatsnew.png", isaudio => 0, name => "What's New", type => "link", }, { # tied Tie::IxHash hasitems => 1, id => 2, image => "plugins/Spotty/html/images/toptracks.png", isaudio => 1, name => "Top Tracks", type => "playlist", url => sub { "???" }, }, { # tied Tie::IxHash hasitems => 1, id => 3, image => "plugins/Spotty/html/images/inbox.png", isaudio => 0, name => "Genres and Moods", type => "link", }, { # tied Tie::IxHash hasitems => 1, id => 4, image => "plugins/Spotty/html/images/inbox.png", isaudio => 0, name => "Afternoon jams", }, { # tied Tie::IxHash hasitems => 1, id => 5, image => "plugins/Spotty/html/images/account.png", isaudio => 0, name => "A's Library", }, { # tied Tie::IxHash hasitems => 1, id => 6, image => "plugins/Spotty/html/images/account.png", isaudio => 0, name => "M's Library", }, { # tied Tie::IxHash hasitems => 1, id => 7, image => "plugins/Spotty/html/images/playlist.png", isaudio => 0, name => "Transfer Playback", type => "link", }, ], }, } But by 291 : my $jsonResponse = to_json($responseRef); The responseRef is either altered, missing or invalid since the error is : [20-08-19 16:48:45.1964] Slim::Web::JSONRPC::handleURI (281) While trying to run function coderef [Slim::Web::JSONRPC::requestMethod]: [encountered CODE(0x659ea38), but JSON can only represent references to arrays or hashes at /usr/share/perl5/Slim/Web/JSONRPC.pm line 291. ] I'm guessing that something in the JSON response is invalid and can't be turned into JSON by the function to_json. Unfortunately I'm not sure what that would be. I'm thinking the suspect is : "url => sub { "???" }," I have traced this to line 215 in the OPML.pm file in the Spotty plugin. If I comment this line out... the JSON gets returned properly. Unfortunately I don't understand why. I think it has something to do with how the url value is returned. the type is "playlist" where the rest are "link". If I change the entry "type => 'playlist'," to "type => 'link'," the JSON gets returned properly. I guess I'm now wondering if "playlist" type entries have to have something special done to them to work with the JSON interface? Also, this "type" appears in several other lists throughout the plugin as far as I can see (from the OPML.pm file). I'm not sure how to find them in the UI but I'm guessing they would break the JSON as well? I'm trying to figure out a way to either change the Spotty plugin, or something else in LMS to allow me to use the Spotty plugin with the JSON RPC interface and I'm not sure where to go from here. Anyone have any ideas? Thanks littla's Profile: http://forums.slimdevices.com/member.php?userid=63581 View this thread: http://forums.slimdevices.com/showthread.php?t=112794 ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins
Re: [SlimDevices: Plugins] Spotty and JSON RPC vs CLI
I dont know anything about the Spotty API and only basics about CLI/JSONRPC but setting logging of jsonrpc to Information helped me a lot to understand where I made my mistakes. There is a typo in your JSON object BTW: the second 0 should be a 10, I guess. karlek's Profile: http://forums.slimdevices.com/member.php?userid=64321 View this thread: http://forums.slimdevices.com/showthread.php?t=112794 ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins
[SlimDevices: Plugins] Spotty and JSON RPC vs CLI
Hello, I've encountered a strange problem and I'd like to know if it's something anyone else has seen and if it's something I'm doing wrong, and maybe what I can do to overcome it. I'm trying to browse the Spotty plugin from software I made for my house (This works for all other plugins until Spotty) and I can't actually do it from the jsonrcp.js method. When I open a telnet session to 9090 and send this: [player mac] spotty items 0 10 want_url:1 I get what I expect : 00%3A00%3A00%3A00%3A00%3A00 spotty items 0 10 want_url%3A1 id%3A0 name%3ASearch type%3Asearch image%3Aplugins%2FSpotty%2Fhtml%2Fimages%2Fsearch.png isaudio%3A0 hasitems%3A1 id%3A1 name%3AWhat's%20New type%3Alink image%3Aplugins%2FSpotty%2Fhtml%2Fimages%2Fwhatsnew.png isaudio%3A0 hasitems%3A1 id%3A2 name%3ATop%20Tracks type%3Aplaylist image%3Aplugins%2FSpotty%2Fhtml%2Fimages%2Ftoptracks.png url%3ACODE(0x59dee40) isaudio%3A1 hasitems%3A1 id%3A3 name%3AGenres%20and%20Moods type%3Alink ... But when I post the foloowing JSON to jsonrcp.js (http port 9000) : { "id" : 3, "method" : "slim.request", "params" : ["00:00:00:00:00:00", ["spotty", "items", "0", "0", "want_url:1"]] } I get no response, just a terminated connection. Do I have to do somewthing in LMS, or to the Spotty plugin to enable it to respond to the JSON RPC? Any help would be greatly appreciated. Thanks! littla's Profile: http://forums.slimdevices.com/member.php?userid=63581 View this thread: http://forums.slimdevices.com/showthread.php?t=112794 ___ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins