[ANSWERED]Integration with Mac Application Radium

Posted on
Tue Sep 29, 2015 4:53 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

[ANSWERED]Integration with Mac Application Radium

For years I have been using the Squeezebox to access Sirius XM and then play it through my Nuvo Concerto system, using Indigo to send commands to the Squeezebox, read the song playing from the Squeezebox and display the information on my Concerto keypads. It was a nice integration and it worked well. Effective today, however, Sirius XM upgraded its transmission and Logitech, the developer behind Squeezebox, refused to update its software to carry the new Sirius XM format. As a result, the Squeezebox is dead as a Sirius XM receiver, at least for now. So I am scrambling to come up with an alternative.

The parameters I am looking for is a product that can receive and stream Sirius XM and play it over external speakers. One option is Sonos, but their hardware is expensive so I would prefer something else. Another idea is to use a Mac application such as Radium that can stream Sirius XM (and then use Airplay with an Apple TV). The issue is how to get Indigo to communicate with Radium, to get track, artist etc, and also to tell Radium what station to play.

Any ideas how I might proceed.

Posted on
Thu Oct 01, 2015 9:30 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Integration with Mac Application Radium

If the Radium app is AppleScriptable, then you should be able to integrate it that way. It will require knowledge of AppleScript though.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Oct 02, 2015 6:30 am
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

Is Applescript preferable to Python for this purpose (as I have used the latter more recently than the former)

Posted on
Fri Oct 02, 2015 9:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Integration with Mac Application Radium

I assume that the Radium app is only AppleScriptable (no other API to talk to it) so I would assume it's AppleScript. Though it may not be AppleScriptable either - I don't know.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Oct 05, 2015 5:04 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

Jay:

Thanks of the help. Radium is Applescriptable. I have some knowledge of Applescript and can determine with Applescript what information (song. artist, station etc) is currently playing, and I can control simple functions like play, pause and stop. All of this is in its dictionary. What I cannot seem to do is set the station to a different one. I can "get" the "station name". I can go into the app itself and change the station. Then when I "get" the "station name" again a different result comes back (very logical). But when I try to "set" a "station name" it fails.
25:37: execution error: Radium got an error: Can’t set station name of application to "Espn". (-10006)

Any ideas?

PS: Radiums support people said only way to set a station is to "create a magnet link for a different station and then use AppleScript to open it like any other file". I asked for more color, but maybe you or someone here has thoughts? Thanks

Posted on
Tue Oct 06, 2015 10:41 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Integration with Mac Application Radium

Unfortunately, I know nothing about how their app is scripted. And I have no clue what they mean in their description. You can search on AppleScript open file to see the various ways to have a script open a file.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Oct 06, 2015 6:24 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]Integration with Mac Application Radium

I don't use Radium, but what I suspect they mean is that you can save a station pre-set to a file that's associated with Radium. That is, one that when opened would start Radium and tune in that station. So if you have that file, you can use AppleScript (or some other method) to "open" the file, which would launch Radium (if necessary) and switch to that station. Just like double-click in the Finder would do.

So I just downloaded the trial of Radium and tested it. I searched for a station, then dragged the station from the list to the desktop. Then in Terminal I entered "open " then dragged in the file from the desktop. I ended up with a command like this:

$ open "radium://tune-in/?b=rockantenne&c=2&pb=Rock%20Antenne&pc=Rock%20Antenne&h=&"

That started Radium and tuned to that station. I created another one the same way, and was able to switch stations by opening the different files alternately.

Doing the same with AppleScript or even Python that issues an "open" command is an exercise for the reader....

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2015 6:03 am
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

So I am a bit dense and deficient in my understanding of python, but I must be close:

In Terminal, I can open a station on Radium with the following:
open "radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&"

In python, I tried the below:
open ('radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&')

Error produced:
File "plugin.py", line 361, in parseToServer
<type 'exceptions.IOError'>: [Errno 2] No such file or directory: 'radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&'

What am I missing?

Posted on
Thu Oct 08, 2015 6:09 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]Integration with Mac Application Radium

The open syscall in Python is not the same as the open command in Terminal. That's why I had "open" in quotes.

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's
icon. If no application name is specified, the default application as determined via LaunchServices is
used to open the specified files.


You want to use the "call" function from the subprocess module: http://stackoverflow.com/questions/8922 ... -in-python

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2015 8:06 am
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

While I think I understand, it still fails:

Code: Select all
subprocess.call ('radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&')

error"
Traceback (most recent call last):
File "plugin.py", line 207, in runConcurrentThread
File "plugin.py", line 247, in parseToServerLine
File "plugin.py", line 362, in parseToServer
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 470, in call
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
<type 'exceptions.OSError'>: [Errno 2] No such file or directory

HOWEVER, I got the below to work (I am open to suggestion how to do with subprocess, which seems to be preferred method):
Code: Select all
os.system('open "radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&"')

NuVo Grand Concerto Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)

Posted on
Thu Oct 08, 2015 8:40 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: [ANSWERED]Integration with Mac Application Radium

You almost had it, I think. Try this:

Code: Select all
subprocess.call (['/usr/bin/open', 'radium://tune-in/?b=siriusxm&c=thespectrum&pb=SiriusXM%20Radio%20USA&pc=SiriusXM%20The%20Spectrum&h=&'])


You didn't specify that it was the 'open' command line utility you wanted to use to open the radium URI. You did when you used the os.system call. I also prefer to give the complete path to the program when possible.

Don't forget the square brackets to make the two strings into a single list argument.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2015 9:40 am
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

That worked. Thanks.

Posted on
Thu Oct 08, 2015 10:03 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: [ANSWERED]Integration with Mac Application Radium

So one more semi-related question. I am trying to tell my plugin what music radium is playing. I found an Applescript that does this:
Code: Select all
tell application id "com.catpigstudios.Radium3"
   if it is running then
   set AA to
      return {track name}
   end if
end tell
Problem is I am having trouble figuring out a good way to pass this information to my python code. I thought maybe putting the applescript code into an embedded Action Group that changes an Indigo variable, but I keep getting an error. Using
Code: Select all
set value of variable "xxxx" to "abcd"
but indigo will not compile set value of variable "xxxx" - is there a better way to adjust the Indigo variable='s value? Even better, is there a good way to just call an applescript from python.? Would be great to code theTrack=script() where script() runs the applescript above

Sorry to be asking such basic questions.

Posted on
Fri Oct 09, 2015 11:07 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Integration with Mac Application Radium

Not sure why it won't compile that line - it looks fine (assuming you have AppleScript selected as the scripting language).

You can execute AppleScripts from Python like this:

Code: Select all
import subprocess
result = subprocess.Popen(['/usr/bin/osascript', '/path/to/applescript.scpt'], stdout=subprocess.PIPE).communicate()[0]
# result will contain whatever the AppleScript returns


It's a bit more complex than subprocess.call explained above because you want to get whatever is returned from the AppleScript. But not that bad.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Oct 09, 2015 12:26 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Integration with Mac Application Radium

I just added a section to the Python Scripting Tutorial called Executing AppleScript that explains a bit more fully how to pass parameters to an AppleScript and receive reply data from an AppleScript from inside a Python script (either embedded or external).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 2 guests