PDA

View Full Version : calling slimserver from external scripts



Laurent Perez
2004-07-15, 07:52
hi

I'd like to add some mouse right-click contextual menu providing
choices like 'append to slimserver playlist/play on slimserver'
behaviours whenever I click on an audio file, much like the
winamp-style 'enqueue in winamp/play in winamp' windows contextual
menus.

I'm thinking about some registry hacking or even calling a perl script
interfacing with slimserver api whenever I right-click on a file, but
I don't know if the slimserver can be called from external functions
like that : is the slimserver API callable from any external
perl/win32 program ? I've tried slim.exe -help, right now I'm thinking
of perl LWP-like web interface remote controler, to "send" requests to
the slimserver, if the core server components aren't directly
callable.

thanks
laurent

Jules Taplin
2004-07-15, 08:13
Hi Laurent.

If you want to talk to it from external fuctions, I'd suggest you use the
'slimserver CLI interface'. It's documented in the 'Technical Information'
page of the slimserver itself...

Basically... you simply open a socket to it, and send it commands, one line
at a time. If you want an example, I suggest you check out either Felix
Mueller's scripts (sorry... don't have a URL immediately to hand - but
they're extensively linked to from the Slim Devices 'plugins' page, or my
'Bemused Bridge' - which I suspect does similar things in terms of
controlling slimserver to what you want
(http://www.mrtickle.org/bemusedbridge.html).

-- Jules



----- Original Message -----
From: "Laurent Perez" <hakimm (AT) gmail (DOT) com>
To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
Sent: Thursday, July 15, 2004 3:52 PM
Subject: [slim] calling slimserver from external scripts


> hi
>
> I'd like to add some mouse right-click contextual menu providing
> choices like 'append to slimserver playlist/play on slimserver'
> behaviours whenever I click on an audio file, much like the
> winamp-style 'enqueue in winamp/play in winamp' windows contextual
> menus.
>
> I'm thinking about some registry hacking or even calling a perl script
> interfacing with slimserver api whenever I right-click on a file, but
> I don't know if the slimserver can be called from external functions
> like that : is the slimserver API callable from any external
> perl/win32 program ? I've tried slim.exe -help, right now I'm thinking
> of perl LWP-like web interface remote controler, to "send" requests to
> the slimserver, if the core server components aren't directly
> callable.
>
> thanks
> laurent
>

mherger
2004-07-15, 10:29
> I'd like to add some mouse right-click contextual menu providing
> choices like 'append to slimserver playlist/play on slimserver'
> behaviours whenever I click on an audio file, much like the
> winamp-style 'enqueue in winamp/play in winamp' windows contextual
> menus.

The main problem will be mapping your local path- and filename to the one
slimserver will understand. Imagine you're running slimserver on a Linux
box, but working on Windows, connected to the server through Samba/Windows
share. The path you and your script are seeing is for example "m:\tony
levin\double espresso\08 - Apollo.mp3" or (as you did not mount the share)
"\\yourslimmachine\music\tony levin\double espresso\08 - Apollo.mp3". But
the server should be looking in "/home/music/files/tony levin/double
espresso/". Hmm...

May be you could keep it configurable: put a variable which will contain
the server's path to your music folder. The script then should translate
your local path to the servers path.

But it still has to handle files that are called from outside the
slimserver's access range, eg. calling a local file "c:\my
music\badsong.mp3" when slimserver's running on a remote box.

This would be pretty cool. Especially if you keep it cross-platform ;-).

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the SlimString Translation Helper
(http://www.herger.net/slim/)

mherger
2004-07-15, 10:58
Hmm... yet another problem that comes to my mind: _which_ player do we
want to play the file? Called from the command line we could easily give a
parameter. But from Windows' context menu? We would have to create an
entry per player. Too much registry tweaking for me...

>> I'd like to add some mouse right-click contextual menu providing
>> choices like 'append to slimserver playlist/play on slimserver'
>> behaviours whenever I click on an audio file, much like the
>> winamp-style 'enqueue in winamp/play in winamp' windows contextual
>> menus.
>
> The main problem will be mapping your local path- and filename to the
> one slimserver will understand. Imagine you're running slimserver on a
> Linux box, but working on Windows, connected to the server through
> Samba/Windows share. The path you and your script are seeing is for
> example "m:\tony levin\double espresso\08 - Apollo.mp3" or (as you did
> not mount the share) "\\yourslimmachine\music\tony levin\double
> espresso\08 - Apollo.mp3". But the server should be looking in
> "/home/music/files/tony levin/double espresso/". Hmm...
>
> May be you could keep it configurable: put a variable which will contain
> the server's path to your music folder. The script then should translate
> your local path to the servers path.
>
> But it still has to handle files that are called from outside the
> slimserver's access range, eg. calling a local file "c:\my
> music\badsong.mp3" when slimserver's running on a remote box.
>
> This would be pretty cool. Especially if you keep it cross-platform ;-).
>



--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

mherger
2004-07-15, 16:18
[..]
> Basically... you simply open a socket to it, and send it commands, one
> line at a time. If you want an example, I suggest you check out either
> Felix
> Mueller's scripts (sorry... don't have a URL immediately to hand - but
[..]

Thanks Felix! I followed Jules' advice and did a quick hack of your
followme.pl to feed my slimserver with a folder's content. You'll need
perl to run this script! Installing slimserver won't be enough on Windows.
It should run on Windows as well as on Linux.

As I mentioned earlier in this thread it will only work, if the selected
files are in the server's music folder. You'll therefore have to configure
the script. There are four important variables to define:

$localFolder: the folder where the file is stored from the client's view
(eg. "m:/songs" on Windows or "/mnt/mp3"

$serverFolder: dito. from the slimserver's point of view. Might be the
same as $localFolder, if you're running slimserver on your local machine.
If not, it must be the same value you defined in the slimserver's
settings, eg. "/home/slimserver/files"

$szServerIP: the slimserver's IP address
$szPlayerName: your player's name as defined in the web-interface

The latter two can be overwritten on the command line (handy if you have
more than one player).

With the above defined you should be able to feed your slimserver by
running the script with the --file parameter. Play a single song:
perl feedmyslim.pl --file="c:/my music/somesong.mp3"

Play all songs (recursively) contained in a folder:
perl feedmyslim.pl --file="c:/my music/Tony Levin/"


The following registry key will allow you to add a folder. Please be sure
to put the path to where you stored the script:

[HKEY_CLASSES_ROOT\Folder\shell\Play on Sqeezebox\command]
@="perl m:\\playmyfile.pl --file=\"%L\""

I don't know yet how to handle single files using a .reg file.

Any comments are welcome. But let's move a discussion about further
enhancements to the developpers list.

Good night,

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

Jules Taplin
2004-07-16, 05:27
Surely we need _ANOTHER_ context menu for 'select active player'? Or a
similar?


-- Jules

----- Original Message -----
From: "Michael Herger" <slim (AT) herger (DOT) net>
To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
Sent: Thursday, July 15, 2004 6:58 PM
Subject: [slim] calling slimserver from external scripts


> Hmm... yet another problem that comes to my mind: _which_ player do we
> want to play the file? Called from the command line we could easily give a
> parameter. But from Windows' context menu? We would have to create an
> entry per player. Too much registry tweaking for me...
>
> >> I'd like to add some mouse right-click contextual menu providing
> >> choices like 'append to slimserver playlist/play on slimserver'
> >> behaviours whenever I click on an audio file, much like the
> >> winamp-style 'enqueue in winamp/play in winamp' windows contextual
> >> menus.
> >
> > The main problem will be mapping your local path- and filename to the
> > one slimserver will understand. Imagine you're running slimserver on a
> > Linux box, but working on Windows, connected to the server through
> > Samba/Windows share. The path you and your script are seeing is for
> > example "m:\tony levin\double espresso\08 - Apollo.mp3" or (as you did
> > not mount the share) "\\yourslimmachine\music\tony levin\double
> > espresso\08 - Apollo.mp3". But the server should be looking in
> > "/home/music/files/tony levin/double espresso/". Hmm...
> >
> > May be you could keep it configurable: put a variable which will contain
> > the server's path to your music folder. The script then should translate
> > your local path to the servers path.
> >
> > But it still has to handle files that are called from outside the
> > slimserver's access range, eg. calling a local file "c:\my
> > music\badsong.mp3" when slimserver's running on a remote box.
> >
> > This would be pretty cool. Especially if you keep it cross-platform ;-).
> >
>
>
>
> --
>
> Michael
>
> -----------------------------------------------------------
> Help translate SlimServer by using the
> SlimString Translation Helper (http://www.herger.net/slim/)
>
>

mherger
2004-07-16, 05:47
> Surely we need _ANOTHER_ context menu for 'select active player'? Or a
> similar?

....or simply add one menu per player. And then we will need an "add to
playlist" (instead of replacing it). I also think that the recursive
addition is a little overdose. A folder's files would imho be enough.

But did it basically work for you? I did not too much testing...

Michael

>
>
> -- Jules
>
> ----- Original Message -----
> From: "Michael Herger" <slim (AT) herger (DOT) net>
> To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
> Sent: Thursday, July 15, 2004 6:58 PM
> Subject: [slim] calling slimserver from external scripts
>
>
>> Hmm... yet another problem that comes to my mind: _which_ player do we
>> want to play the file? Called from the command line we could easily
>> give a
>> parameter. But from Windows' context menu? We would have to create an
>> entry per player. Too much registry tweaking for me...
>>
>> >> I'd like to add some mouse right-click contextual menu providing
>> >> choices like 'append to slimserver playlist/play on slimserver'
>> >> behaviours whenever I click on an audio file, much like the
>> >> winamp-style 'enqueue in winamp/play in winamp' windows contextual
>> >> menus.
>> >
>> > The main problem will be mapping your local path- and filename to the
>> > one slimserver will understand. Imagine you're running slimserver on a
>> > Linux box, but working on Windows, connected to the server through
>> > Samba/Windows share. The path you and your script are seeing is for
>> > example "m:\tony levin\double espresso\08 - Apollo.mp3" or (as you did
>> > not mount the share) "\\yourslimmachine\music\tony levin\double
>> > espresso\08 - Apollo.mp3". But the server should be looking in
>> > "/home/music/files/tony levin/double espresso/". Hmm...
>> >
>> > May be you could keep it configurable: put a variable which will
>> contain
>> > the server's path to your music folder. The script then should
>> translate
>> > your local path to the servers path.
>> >
>> > But it still has to handle files that are called from outside the
>> > slimserver's access range, eg. calling a local file "c:\my
>> > music\badsong.mp3" when slimserver's running on a remote box.
>> >
>> > This would be pretty cool. Especially if you keep it cross-platform
>> ;-).
>> >
>>
>>
>>
>> --
>>
>> Michael
>>
>> -----------------------------------------------------------
>> Help translate SlimServer by using the
>> SlimString Translation Helper (http://www.herger.net/slim/)
>>
>>

Roy M. Silvernail
2004-07-16, 07:58
Jules Taplin wrote:

>Surely we need _ANOTHER_ context menu for 'select active player'? Or a
>similar?
>
>
To be most windows-like, this should be an entry off the 'Send To'
context menu named "SlimServer", and if there are multiple players, the
SlimServer entry should drop a further menu to select the player. But
at this level of functionality, you've passed up what can be achieved by
a simple registry entry. You'll need a shell extension DLL to do it right.

(I spent half of yesterday in a functionality review meeting for my day
job's Windows products. Just shoot me now, OK? :) )

--
Roy M. Silvernail is roy (AT) rant-central (DOT) com, and you're not
"It's just this little chromium switch, here." - TFS
SpamAssassin->procmail->/dev/null->bliss
http://www.rant-central.com

mherger
2004-07-16, 08:16
>> Surely we need _ANOTHER_ context menu for 'select active player'? Or a
>> similar?
>>
> To be most windows-like, this should be an entry off the 'Send To'
> context menu named "SlimServer", and if there are multiple players, the
> SlimServer entry should drop a further menu to select the player. But
> at this level of functionality, you've passed up what can be achieved by
> a simple registry entry. You'll need a shell extension DLL to do it
> right.

If we forget about the second level, the "send to" could ease things:
aren't these simple shortcuts in a special folder? If I wasn't leaving for
a long week-end, I would give it a try tonight...

--

Michael

-----------------------------------------------------------
http://www.jo-sac.ch - JO-SAC inoffiziell!
http://www.herger.net/photo - mein kleines Photoalbum

Jules Taplin
2004-07-16, 09:00
Hmmm. Actually... not so far.

I'm guessing I'm having a trouble with the correct escaping of characters -
more information as I work it out.


-- Jules

----- Original Message -----
From: "Michael Herger" <slim (AT) herger (DOT) net>
To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
Sent: Friday, July 16, 2004 1:47 PM
Subject: [slim] calling slimserver from external scripts


> > Surely we need _ANOTHER_ context menu for 'select active player'? Or a
> > similar?
>
> ...or simply add one menu per player. And then we will need an "add to
> playlist" (instead of replacing it). I also think that the recursive
> addition is a little overdose. A folder's files would imho be enough.
>
> But did it basically work for you? I did not too much testing...
>
> Michael
>
> >
> >
> > -- Jules
> >
> > ----- Original Message -----
> > From: "Michael Herger" <slim (AT) herger (DOT) net>
> > To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
> > Sent: Thursday, July 15, 2004 6:58 PM
> > Subject: [slim] calling slimserver from external scripts
> >
> >
> >> Hmm... yet another problem that comes to my mind: _which_ player do we
> >> want to play the file? Called from the command line we could easily
> >> give a
> >> parameter. But from Windows' context menu? We would have to create an
> >> entry per player. Too much registry tweaking for me...
> >>
> >> >> I'd like to add some mouse right-click contextual menu providing
> >> >> choices like 'append to slimserver playlist/play on slimserver'
> >> >> behaviours whenever I click on an audio file, much like the
> >> >> winamp-style 'enqueue in winamp/play in winamp' windows contextual
> >> >> menus.
> >> >
> >> > The main problem will be mapping your local path- and filename to the
> >> > one slimserver will understand. Imagine you're running slimserver on
a
> >> > Linux box, but working on Windows, connected to the server through
> >> > Samba/Windows share. The path you and your script are seeing is for
> >> > example "m:\tony levin\double espresso\08 - Apollo.mp3" or (as you
did
> >> > not mount the share) "\\yourslimmachine\music\tony levin\double
> >> > espresso\08 - Apollo.mp3". But the server should be looking in
> >> > "/home/music/files/tony levin/double espresso/". Hmm...
> >> >
> >> > May be you could keep it configurable: put a variable which will
> >> contain
> >> > the server's path to your music folder. The script then should
> >> translate
> >> > your local path to the servers path.
> >> >
> >> > But it still has to handle files that are called from outside the
> >> > slimserver's access range, eg. calling a local file "c:\my
> >> > music\badsong.mp3" when slimserver's running on a remote box.
> >> >
> >> > This would be pretty cool. Especially if you keep it cross-platform
> >> ;-).
> >> >
> >>
> >>
> >>
> >> --
> >>
> >> Michael
> >>
> >> -----------------------------------------------------------
> >> Help translate SlimServer by using the
> >> SlimString Translation Helper (http://www.herger.net/slim/)
> >>
> >>

Jules Taplin
2004-07-16, 09:17
Ah. No. Made it work this time. Managed to not only add the wrong registry
key... but even while testing... I managed to get my case-sensitivity wrong.
:(

All looks to work for me.


-- Jules

----- Original Message -----
From: "Michael Herger" <slim (AT) herger (DOT) net>
To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
Sent: Friday, July 16, 2004 1:47 PM
Subject: [slim] calling slimserver from external scripts


> > Surely we need _ANOTHER_ context menu for 'select active player'? Or a
> > similar?
>
> ...or simply add one menu per player. And then we will need an "add to
> playlist" (instead of replacing it). I also think that the recursive
> addition is a little overdose. A folder's files would imho be enough.
>
> But did it basically work for you? I did not too much testing...
>
> Michael
>
> >
> >
> > -- Jules
> >
> > ----- Original Message -----
> > From: "Michael Herger" <slim (AT) herger (DOT) net>
> > To: "Slim Devices Discussion" <discuss (AT) lists (DOT) slimdevices.com>
> > Sent: Thursday, July 15, 2004 6:58 PM
> > Subject: [slim] calling slimserver from external scripts
> >
> >
> >> Hmm... yet another problem that comes to my mind: _which_ player do we
> >> want to play the file? Called from the command line we could easily
> >> give a
> >> parameter. But from Windows' context menu? We would have to create an
> >> entry per player. Too much registry tweaking for me...
> >>
> >> >> I'd like to add some mouse right-click contextual menu providing
> >> >> choices like 'append to slimserver playlist/play on slimserver'
> >> >> behaviours whenever I click on an audio file, much like the
> >> >> winamp-style 'enqueue in winamp/play in winamp' windows contextual
> >> >> menus.
> >> >
> >> > The main problem will be mapping your local path- and filename to the
> >> > one slimserver will understand. Imagine you're running slimserver on
a
> >> > Linux box, but working on Windows, connected to the server through
> >> > Samba/Windows share. The path you and your script are seeing is for
> >> > example "m:\tony levin\double espresso\08 - Apollo.mp3" or (as you
did
> >> > not mount the share) "\\yourslimmachine\music\tony levin\double
> >> > espresso\08 - Apollo.mp3". But the server should be looking in
> >> > "/home/music/files/tony levin/double espresso/". Hmm...
> >> >
> >> > May be you could keep it configurable: put a variable which will
> >> contain
> >> > the server's path to your music folder. The script then should
> >> translate
> >> > your local path to the servers path.
> >> >
> >> > But it still has to handle files that are called from outside the
> >> > slimserver's access range, eg. calling a local file "c:\my
> >> > music\badsong.mp3" when slimserver's running on a remote box.
> >> >
> >> > This would be pretty cool. Especially if you keep it cross-platform
> >> ;-).
> >> >
> >>
> >>
> >>
> >> --
> >>
> >> Michael
> >>
> >> -----------------------------------------------------------
> >> Help translate SlimServer by using the
> >> SlimString Translation Helper (http://www.herger.net/slim/)
> >>
> >>

Jules Taplin
2004-07-16, 09:20
> To be most windows-like, this should be an entry off the 'Send To'
> context menu named "SlimServer", and if there are multiple players, the
> SlimServer entry should drop a further menu to select the player. But
> at this level of functionality, you've passed up what can be achieved by
> a simple registry entry. You'll need a shell extension DLL to do it
right.
>
> (I spent half of yesterday in a functionality review meeting for my day
> job's Windows products. Just shoot me now, OK? :) )

Surely we should have shot you yesterday morning. Same result... but with
half a day's less pain ;)

(Sounds like the right answer, though. Although I wonder if we're
over-engineering slightly...)

-- Jules

Roy M. Silvernail
2004-07-16, 12:38
Jules Taplin wrote:

>Surely we should have shot you yesterday morning. Same result... but with
>half a day's less pain ;)
>
>
True enough!

>(Sounds like the right answer, though. Although I wonder if we're
>over-engineering slightly...)
>
>
Over-engineering? No such thing! If we can, we must! :)

And to answer Michael in the same breath, yes: 'Send To' is a special
folder that can hold simple shortcuts as well as triggers for extension
DLLs. Some of the Power Toys shell extensions (target menu and Send To
Any Folder from Power Toys are two examples) use extension DLLs. If I
remember right, a simple shortcut will pass the filename as the first
command line parameter. It doesn't look like simple shortcuts can make
use of the %s substitution.

--
Roy M. Silvernail is roy (AT) rant-central (DOT) com, and you're not
"It's just this little chromium switch, here." - TFS
SpamAssassin->procmail->/dev/null->bliss
http://www.rant-central.com

jaysung
2009-06-20, 08:19
Hello,
I just wanted to ask if there is any further developement on the playing from win explorer function.
That would be cool.
Thanks
Jay