PDA

View Full Version : Playlist "Macro" URL Commands - Maybe Kidsplay?



spedinfargo
2010-05-03, 15:57
Hi,

I'm VERY close to getting streaming radio from my Denon 3808 receiver via the WaveInput plugin to go through the Squeezeboxen in the house.

I found a very simple way to control the Denon receiver via HTTP commands which I picked out of their web pages served by the internal web server.

For instance, these commands start Zone 2 and change the radio station to preset A4:

http://192.168.1.6/ZONE2/s_zone2.asp?radioPower2=ON
http://192.168.1.6/ZONE2/TUNER/s_TunerPreset.asp?listPreset=A4

What I need is a way to send these commands to the tuner, and then fire up the WaveInput plugin.

I manually created an M3U playlist with the two commands and then the wavein:0.

This ALMOST works - but I need to hit "next track" on the remote to go from what the squeezebox thinks is three separate tracks. When I cycle through, it does turn on Zone two and changes the radio station and then streams it, so it works in this regard.

Is there a way to do this without the "next track" button? I'm going to explore Kidsplay plugin to see if that does what I need. Maybe I should look into the M3U format a bit more (EXTINF, etc.).

Any thoughts?

peterw
2010-05-03, 19:44
We (3rd party folks) have talked a few times about making a "cli" protocol handler so you could have an .M3U with entries like

squeezecli://player=00%3A04%3A20%3A11%3A22%3A33&p0=button&p1=fwd

to execute commands when you select a playlist, but there are some inherent risks there. You don't want to open an HTTP address that delivers an M3U with squeezecli: URLs that do things you don't want, like change your Music Directory setting.

If you're using an infrared remote, then KidsPlay can definitely get you most of the way there, maybe all the way there. But you haven't said how you'd like to kick this all off, which would be a big factor.

Maybe another feature for KidsPlay would do it. Please install KidsPlay and take a look at the 'kidsplayexec' documentation on the KidsPlay global settings page. What if there was a KidsPlay protocol handler such that you could have a URL in your M3U like

kidsplaymacro://player=00%3A04%3A20%3A11%3A22%3A33&secret=123456&type=JVC&button=0

which, if the "secret" value matched that for your server (and you had done the other things to enable kidsplayexec), would execute the KidsPlay macro you programmed for JVC button "0"?

Or maybe this should be a completely new plugin that would take URLs like

squeezecli://player=00%3A04%3A20%3A11%3A22%3A33&secret=123456&p0=button&p1=fwd

peterw
2010-05-03, 21:06
Earlier discussion that's relevant: http://forums.slimdevices.com/showthread.php?t=64163

spedinfargo
2010-05-04, 12:44
Earlier discussion that's relevant: http://forums.slimdevices.com/showthread.php?t=64163

Thanks for the responses - I'll definitely look at the Kidsplayexec for running.

Ideally I would want to be able to run this from either a button on the Radio or a Favorite from the Controller or SBS Web interface. Can I run a Kidsplay macro as a Favorite?

I'll have to keep playing around with it and report back here...

peterw
2010-05-04, 15:59
Ideally I would want to be able to run this from either a button on the Radio or a Favorite from the Controller or SBS Web interface. Can I run a Kidsplay macro as a Favorite?


I don't think so -- it's only designed to run macros in response to Boom/Radio/Receiver buttons or IR activity, or via the CLI (though I haven't really documented running a macro via CLI).

peterw
2010-05-04, 19:45
Try adding my test repo (http://www.tux.org/~peterw/slim/slim7/repodata-test.xml) and installing my new SqueezeCLIHandler plugin. It adds two new protocol handlers: squeezecli and squeezeexec. In order to use them, you must enable password protection on Squeezebox Server and set CSRF protection to Medium or High (and restart SBS after doing so!). The protocol URLs look like



# turn this player off (CLI command "power 0")
squeezecli:secret=123456789012&p0=power&p1=0
# turn off the player with ID 00:04:20:11:22:33
squeezecli:secret=123456789012&p0=power&p1=0&player=00%3A04%3A20%3A11%3A22%3A33
# execute the command "/usr/bin/touch" on the SBS host, passing one argument, "/tmp/somefile"
squeezeexec:secret=123456789012&p0=/usr/bin/touch&p1=/tmp/somefile

Right now you'll need to try a URL like squeezecli:secret=123456789012&p0=power&p1=0 and look at the server logs to determine the correct "secret" value for your system. You'll see an error message like " 'secret' not valid in squeezecli:secret=123456789012&p0=power&p1=0 -- should be 98765432101"

You must always pass a "secret" value and a "p0" value (the naming for "p0" is taken from historical SBS URL param names). You may pass as many "pN" values as you need. All name=value pairs must URI-encode the value strings. A "player" argument is optional for squeezecli, and can be used to specify that the CLI command should run on the specified player rather than the player currently trying to "play" the squeezecli URL (if you don't include a "player" arg, the command will run on the player playing the URL). You can specify "player" for squeezeexec, too, but it has no effect there.

Please let me know what you think.

peterw
2010-05-04, 21:12
This ALMOST works - but I need to hit "next track" on the remote to go from what the squeezebox thinks is three separate tracks. When I cycle through, it does turn on Zone two and changes the radio station and then streams it, so it works in this regard.

Is there a way to do this without the "next track" button?

I was thinking more about this specific example. I think what you'd want to do is make a shell or batch script to request your URLs like "http://192.168.1.6/ZONE2/s_zone2.asp?radioPower2=ON" -- in Linux or Mac shell, I'd use wget or curl; on Windows I'd probably use PowerShell and System.Net.WebClent. Then you could have a playlist using squeezeexec to run your shell/batch script.

There's a huge functional flaw in my current code -- neither handler properly tells SBS that it's done. So, as you found in your testing, you get stuck on that playlist entry.

peterw
2010-05-05, 05:40
There's a huge functional flaw in my current code -- neither handler properly tells SBS that it's done. So, as you found in your testing, you get stuck on that playlist entry.

Release 0.2 fixes that problem. Note: I have only tested with SBS 7.5 so far. Now my biggest annoyance is that the web UI shows a blank line for these URLs when viewing a playlist.

peterw
2010-05-05, 19:26
0.3 mostly fixes the UI problems -- the first time SBS asks my protocol handler for metadata on the URL, my plugin registers info with SBS that's used in the various UIs.

Along with that, there's a new arg you can put in squeezecli: and squeezeexec: URLs: "title". If set, that arg will be the title displayed in the various UIs. For instance,


squeezecli:secret=123456789012&p0=power&p1=0&title=Turn%20player%20off

would be labeled "Turn player off" in the various UIs. If you don't set a "title" arg, the UI will show a simplified URL (with the "secret" arg redacted), e.g. for "squeezecli:secret=123456789012&p0=power&p1=0" you would see the track title "squeezecli:&p0=power&p1=0".

spedinfargo
2010-05-06, 14:30
Peter - thanks for playing around with this. Much appreciated.

Can you check the zip file for the latest version? I think it might be missing the ProtocolHandler.pm file.

I've actually considered brushing off my old Perl skills and hacking through a plugin to control the Denon tuner as its own handler - kind of a combination of the Wavin and yours and the other Denon plugin. I've kinda figured out how the whole protocol handler thing works and I'm actually pretty close to getting it to do what I want.

Need to figure out if I can just have my plugin hand itself off to the WaveInput plugin (which I should be able to do by just changing the Now Playing stream, right?).

I've got a month off of work coming up in a week or so - I needed something to keep me occupied anyway...

sped



0.3 mostly fixes the UI problems -- the first time SBS
asks my protocol handler for metadata on the URL, my plugin registers info with SBS that's used in the various UIs.

Along with that, there's a new arg you can put in squeezecli: and squeezeexec: URLs: "title". If set, that arg will be the title displayed in the various UIs. For instance,


squeezecli:secret=123456789012&p0=power&p1=0&title=Turn%20player%20off

would be labeled "Turn player off" in the various UIs. If you don't set a "title" arg, the UI will show a simplified URL (with the "secret" arg redacted), e.g. for "squeezecli:secret=123456789012&p0=power&p1=0" you would see the track title "squeezecli:&p0=power&p1=0".

peterw
2010-05-06, 15:26
Peter - thanks for playing around with this. Much appreciated.

Can you check the zip file for the latest version? I think it might be missing the ProtocolHandler.pm file.

Yeah, try 0.4. I had a typo in my external manifest file. Sorry.


I've actually considered brushing off my old Perl skills and hacking through a plugin to control the Denon tuner as its own handler - kind of a combination of the Wavin and yours and the other Denon plugin. I've kinda figured out how the whole protocol handler thing works and I'm actually pretty close to getting it to do what I want.

Sounds nice. And fun. I don't know if you've looked at my DenonSerial plugin, but it should be pretty easy to add a CLI command for sending Denon commands through it. You might ask Aesculus about doing the same for his. I'm thinking something like


00:04:20:11:22:33 denonserial send MUON

to tell my plugin to mute the master zone for the amp associated with that Squeezebox. In SqueezeCLIHandler (which I think I'm going to rename something like ActionTracks), you could have a playlist item like squeezecli:secret=NNN&p0=denonserial&p1=send&p2=MUON&title=Mute%20the%20amp


Need to figure out if I can just have my plugin hand itself off to the WaveInput plugin (which I should be able to do by just changing the Now Playing stream, right?

I haven't played with WaveInput, so I'm afraid I'm not much help there. :-(

peterw
2010-05-06, 20:59
I just hit an ugly bug that threatens this whole commands-in-playlist idea: http://bugs.slimdevices.com/show_bug.cgi?id=16188

Essentially, the Squeezebox Server scanner does not, and cannot, recognize any protocols other than those that ship with the software. You can build a playlist with custom protocol URLs in the SBS web interface, but if you ask SBS to rescan the library, it will not recognize your (properly registered and 100% playable!) custom URL protocol in the M3U playlist, and if you try playing your playlist, SBS will skip your custom protocol lines.

If you're running the Perl version of SBS, you can manually hack the scanner.pl application, adding your protocols to the @handlers array that's declared around line 370. That's the only way I've found so far to make this viable, which means that unless SBS is improved, custom protocols in playlists will only be usable by moderately geeky Linux/Mac users and extremely geeky Windows users. :-(