Hi everyone,
I am trying to control the slimserver from iTunes: i.e., to play the
currently playing song in iTunes on my SqueezeBox. I have looked
through the archives, but not seen such an option or plugin. Does
anybody know how to do such a thing or am I overlooking the obvious
here?
Help is appreciated,
Thanks a lot,
Greetings, Anton.
Results 1 to 10 of 33
Thread: Control SlimServer _from_ iTunes
-
2004-10-02, 02:42 #1Anton F. van der KraaijGuest
Control SlimServer _from_ iTunes
-
2004-10-02, 04:09 #2Oscar MarshGuest
Control SlimServer _from_ iTunes
On 2 Oct 2004, at 10:42 am, Anton F. van der Kraaij wrote:
> Hi everyone,
>
> I am trying to control the slimserver from iTunes: i.e., to play the
> currently playing song in iTunes on my SqueezeBox. I have looked
> through the archives, but not seen such an option or plugin. Does
> anybody know how to do such a thing or am I overlooking the obvious
> here?
>
> Help is appreciated,
>
> Thanks a lot,
>
> Greetings, Anton.
Hi Anton
What OS are you using? It would be trivial with a little research for
me to work out an AppleScript which would go a short way towards doing
what you want. If you're on Windows, sorry :^)
Oscar Marsh
--
jabber: ojmarsh (AT) amessage (DOT) at
-
2004-10-02, 04:16 #3Anton F. van der KraaijGuest
Control SlimServer _from_ iTunes
Hi Oscar,
I am using SlimServer on MacOS. Would it be easy to do such a thing in
AppleScript? I dont use AppleScript very often I am afraid, so your
help would be greatly appreciated.
Greetings,
Anton.
-
2004-10-02, 05:48 #4Oscar MarshGuest
Control SlimServer _from_ iTunes
> Hi Oscar,
>
> I am using SlimServer on MacOS. Would it be easy to do such a thing in
> AppleScript? I dont use AppleScript very often I am afraid, so your
> help would be greatly appreciated.
>
> Greetings,
>
> Anton.
I'm working on a script that takes the tracks from the currently
showing playlist in iTunes, adds them to the active playlist on
SlimServer, and plays it. I'm having problems using curl, can anyone
help? wget handles this URL correctly when quoted:
"http://10.0.1.2:9000/status.html?p0=playlist&p1=add&p2=/Volumes/
SmartDisk 120 GB/Music/Aphex Twin/drukqs/02 vord hosbn.mp3"
curl doesn't do the action.
Meanwhile, Anton, see here:
http://lists.slimdevices.com/archive...er/022031.html
for a similar script which was written last year for a similar purpose.
Oscar Marsh
--
jabber: ojmarsh (AT) amessage (DOT) at
-
2004-10-02, 07:13 #5Anton F. van der KraaijGuest
Control SlimServer _from_ iTunes
Hi Oscar,
the script you mentioned indeed works and does something similar. It
however adds whole albums etc.. and thus is not always an exact replica
of what iTunes is playing. I took a look at the script and as far as I
can understand what I need is something similar and very smal:
1. Check what the path to the filename is that is currently playing
2. if different from previous filename, stop current song on slimserver
and start new song.
(And this in this idle loop) I dont know how to ask the filename of the
currently playing song. How do I do this?
> "http://10.0.1.2:9000/status.html?p0=playlist&p1=add&p2=/Volumes/
> SmartDisk 120 GB/Music/Aphex Twin/drukqs/02 vord hosbn.mp3"
In regards to your question, I think for curl you need to replace the
'/' with '%2f' and the spaces in a filename with '%20'
If I do the following in a terminal, the slimserver starts playing,
using curl:
curl
"http://127.0.0.1:9000/status.html?
p0=playlist&p1=play&p2=%2fVolumes%2fMMEDIA%2fmp3%2 fEnya%2ftest.mp3"
hope this helps.
Greetings, Anton.
-
2004-10-02, 09:06 #6Oscar MarshGuest
Control SlimServer _from_ iTunes
> Hi Oscar,
Hiya
> the script you mentioned indeed works and does something similar. It
> however adds whole albums etc.. and thus is not always an exact
> replica of what iTunes is playing. I took a look at the script and as
> far as I can understand what I need is something similar and very
> smal:
>
> 1. Check what the path to the filename is that is currently playing
> 2. if different from previous filename, stop current song on
> slimserver and start new song.
>
> (And this in this idle loop) I dont know how to ask the filename of
> the currently playing song. How do I do this?
Well, my script doesn't monitor what's playing because I don't like
stay-open scripts. Instead, you would build a playlist in iTunes then
run the script from your iTunes scripts menu, and it will clear the
Slim playlist, add the contents of the iTunes playlist, and play it. If
you want to get the path of the current song you need something like
the following in your script:
set theLoc to POSIX path of (location of current track)
this gives you a UNIX-style path.
>
>> "http://10.0.1.2:9000/status.html?p0=playlist&p1=add&p2=/Volumes/
>> SmartDisk 120 GB/Music/Aphex Twin/drukqs/02 vord hosbn.mp3"
>
> In regards to your question, I think for curl you need to replace the
> '/' with '%2f' and the spaces in a filename with '%20'
Oh no, I was dreading you'd say that! Find and replace is not something
I find easy to do in scripts.
Oscar Marsh
--
jabber: ojmarsh (AT) amessage (DOT) at
-
2004-10-02, 09:12 #7Anton F. van der KraaijGuest
Control SlimServer _from_ iTunes
Hi Everyone,
Well I think I have a solution for my problem. This applescript will
check if a song is playing in iTunes. If that is the case, it will play
it in the SlimServer. There is a check made for special symbols in
filenames. My guess is that some symbols are not fully supported yet
(it works for my library so far). Save it as an application and don't
forget to tick the 'stay open' checkbox. Probably still bugs or
features missing, but it is a start :-)
Hope this helps. Oscar, thanks for your help and the link to the old
post.
Greetings,
Anton.
-- Begin of Script
-- iSlimServer: Control SlimServer from iTunes
-- Plays whatever song is currently playing in iTunes on the SlimServer
-- Copyright Anton F. van der Kraaij 2004
-- Thanks to a script by Barry Brown for inspiration and help from
Oscar Marsch
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- INSTRUCTIONS:
-- Set your variables server_address and server_port to your situation
-- Save this script as an application, making sure to click 'stay open'
global server_address, server_port, current_file_track
set server_address to "127.0.0.1" -- This is the slimserver's address
set server_port to "9000" -- This is the slimserver's port
set current_file_track to ""
on idle
try
tell application "Finder"
if (get name of every process) contains "iTunes" then set okflag to
true
end tell
if okflag then
-- iTunes is running. Check if it is playing a song.
tell application "iTunes"
if player state is paused or player state is stopped then
-- iTunes is not playing. Stop slimserver.
do shell script ("curl \"http://" & server_address & ":" &
server_port & "/status.html?p0=stop\"")
set okflag to false
return 10
end if
end tell
end if
if okflag then
tell application "iTunes"
if class of current track is file track then
try
copy current track's location to file_path_of_track
on error errText
display dialog errText buttons {"Cancel"} with icon 0
end try
end if -- not a file track
-- return file_path_of_track
if (current_file_track is not file_path_of_track) then
-- File in iTunes is different than file on SlimServer.
-- Thus update variable
set current_file_track to file_path_of_track
-- convert mac path to unix path for use in URL with curl (be
careful with special characters here)
set mac_path to (file_path_of_track as text)
set root to (offset of ":" in mac_path)
set rootdisk to (characters 1 thru (root - 1) of mac_path)
tell application "Finder"
if (disk (rootdisk as string) is the startup disk) then
set unixpath to "%2f" & (characters (root + 1) thru end of
mac_path)
else
set unixpath to "%2fVolumes:" & mac_path
end if
end tell
set chars to every character of unixpath
repeat with i from 2 to length of chars
if item i of chars as text is equal to "/" then
set item i of chars to ":"
else if item i of chars as text is equal to ":" then
set item i of chars to "%2f"
else if item i of chars as text is equal to "\"" then
set item i of chars to "\\" & "\""
else if item i of chars as text is equal to "*" then
set item i of chars to "\\*"
else if item i of chars as text is equal to "?" then
set item i of chars to "\\?"
else if item i of chars as text is equal to " " then
set item i of chars to "%20"
else if item i of chars as text is equal to "+" then
set item i of chars to "%2b"
else if item i of chars as text is equal to "&" then
set item i of chars to "%26"
else if item i of chars as text is equal to "\\" then
set item i of chars to "\\\\"
end if
end repeat
set filetoplay to every item of chars as string
-- end conversion
-- Tell slimserver to stop current song and play the song
currently playing in iTunes
do shell script ("curl \"http://" & server_address & ":" &
server_port & "/status.html?p0=stop\"")
do shell script ("curl \"http://" & server_address & ":" &
server_port & "/status.html?p0=playlist&p1=play&p2=" & filetoplay &
"\"")
end if
end tell
end if
end try
return 10
end idle
-- end of script
-
2004-10-02, 09:16 #8Anton F. van der KraaijGuest
Control SlimServer _from_ iTunes
Hi,
> Oh no, I was dreading you'd say that! Find and replace is not
> something I find easy to do in scripts.
>
I found something that solves your problem. See the script I just sent.
I haven't figured out how to do functions in Scripts, so the script was
one big piece of text :-(
Greetings,
Anton.
-
2004-10-02, 11:03 #9Oscar MarshGuest
Control SlimServer _from_ iTunes
On 2 Oct 2004, at 5:12 pm, Anton F. van der Kraaij wrote:
> This applescript will check if a song is playing in iTunes. If that is
> the case, it will play it in the SlimServer. There is a check made for
> special symbols in filenames.
Anton, great job on this script, and especially the character-changing
routine!
Oscar Marsh
--
jabber: ojmarsh (AT) amessage (DOT) at
-
2004-10-02, 11:50 #10Jonathan GreeneGuest
Control SlimServer _from_ iTunes
WOW! -- This totally rocks!
I just updated my server to 5.3.1 and am hoping that a long standing
issue I have with my Slim losing contact with iTunes won't creep back
now that I can control my Slimp3 from iTunes. This is a fantastic
script! There's a small delay between players which is just fine for
me since they are in the same room and I'll just mute the computer
while jamming on the stereo.
Thanks Anton!
On Oct 2, 2004, at 12:12 PM, Anton F. van der Kraaij wrote:
> Hi Everyone,
>
> Well I think I have a solution for my problem. This applescript will
> check if a song is playing in iTunes. If that is the case, it will
> play it in the SlimServer. There is a check made for special symbols
> in filenames. My guess is that some symbols are not fully supported
> yet (it works for my library so far). Save it as an application and
> don't forget to tick the 'stay open' checkbox. Probably still bugs or
> features missing, but it is a start :-)
>
> Hope this helps. Oscar, thanks for your help and the link to the old
> post.
>
> Greetings,
>
> Anton.
>
> -- Begin of Script
> -- iSlimServer: Control SlimServer from iTunes
> -- Plays whatever song is currently playing in iTunes on the SlimServer
> -- Copyright Anton F. van der Kraaij 2004
> -- Thanks to a script by Barry Brown for inspiration and help from
> Oscar Marsch
> --
> -- This program is free software; you can redistribute it and/or modify
> -- it under the terms of the GNU General Public License as published by
> -- the Free Software Foundation; either version 2 of the License, or
> -- (at your option) any later version.
> --
> -- This program is distributed in the hope that it will be useful,
> -- but WITHOUT ANY WARRANTY; without even the implied warranty of
> -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -- GNU General Public License for more details.
> --
> -- INSTRUCTIONS:
> -- Set your variables server_address and server_port to your situation
> -- Save this script as an application, making sure to click 'stay open'
>
> global server_address, server_port, current_file_track
>
> set server_address to "127.0.0.1" -- This is the slimserver's address
> set server_port to "9000" -- This is the slimserver's port
>
> set current_file_track to ""
>
> on idle
> try
> tell application "Finder"
> if (get name of every process) contains "iTunes" then set okflag to
> true
> end tell
> if okflag then
> -- iTunes is running. Check if it is playing a song.
> tell application "iTunes"
> if player state is paused or player state is stopped then
> -- iTunes is not playing. Stop slimserver.
> do shell script ("curl \"http://" & server_address & ":" &
> server_port & "/status.html?p0=stop\"")
> set okflag to false
> return 10
> end if
> end tell
> end if
> if okflag then
> tell application "iTunes"
> if class of current track is file track then
> try
> copy current track's location to file_path_of_track
> on error errText
> display dialog errText buttons {"Cancel"} with icon 0
> end try
> end if -- not a file track
> -- return file_path_of_track
> if (current_file_track is not file_path_of_track) then
> -- File in iTunes is different than file on SlimServer.
> -- Thus update variable
> set current_file_track to file_path_of_track
>
> -- convert mac path to unix path for use in URL with curl (be
> careful with special characters here)
> set mac_path to (file_path_of_track as text)
> set root to (offset of ":" in mac_path)
> set rootdisk to (characters 1 thru (root - 1) of mac_path)
> tell application "Finder"
> if (disk (rootdisk as string) is the startup disk) then
> set unixpath to "%2f" & (characters (root + 1) thru end of
> mac_path)
> else
> set unixpath to "%2fVolumes:" & mac_path
> end if
> end tell
> set chars to every character of unixpath
> repeat with i from 2 to length of chars
> if item i of chars as text is equal to "/" then
> set item i of chars to ":"
> else if item i of chars as text is equal to ":" then
> set item i of chars to "%2f"
> else if item i of chars as text is equal to "\"" then
> set item i of chars to "\\" & "\""
> else if item i of chars as text is equal to "*" then
> set item i of chars to "\\*"
> else if item i of chars as text is equal to "?" then
> set item i of chars to "\\?"
> else if item i of chars as text is equal to " " then
> set item i of chars to "%20"
> else if item i of chars as text is equal to "+" then
> set item i of chars to "%2b"
> else if item i of chars as text is equal to "&" then
> set item i of chars to "%26"
> else if item i of chars as text is equal to "\\" then
> set item i of chars to "\\\\"
> end if
> end repeat
> set filetoplay to every item of chars as string
> -- end conversion
> -- Tell slimserver to stop current song and play the song
> currently playing in iTunes
> do shell script ("curl \"http://" & server_address & ":" &
> server_port & "/status.html?p0=stop\"")
> do shell script ("curl \"http://" & server_address & ":" &
> server_port & "/status.html?p0=playlist&p1=play&p2=" & filetoplay &
> "\"")
> end if
> end tell
> end if
> end try
> return 10
> end idle
> -- end of script
>
>

Reply With Quote
