Integrate Sirius

From MythTV Official Wiki
Revision as of 00:15, 8 April 2007 by TwoOneSix (talk | contribs) (Create files)

Jump to: navigation, search

This article is going to give you all of the info you need in order to pipe your online Sirius Satellite Radio account directly through your MythTV system. The first draft of this article is based around a Fedora Core 6 setup but it can be EASILY adapted to any distro. Please, READ THE ENTIRE ARTICLE CAREFULLY all the way to the end before you start anything.


Important.png Note: this is NOT a plug-in and is basically a hack but when completed it looks just like a plug-in.


Article from 10,000 feet

What this article is...

This article IS about:

  • Setting up MythTV to play streams from Sirius Radio Online
  • How-To use programs that other people wrote (and are not affiliated with MythTV)
  • How-To integrate everything with the default MythTV menu theme

What this article is not...

This article IS NOT:

  • How-To get free access to the streams (although a Sirius online guest account will work fine)
  • How-To perfectly integrate with your particular MythTV GUI (we only cover the default menu theme)
  • A Sirius Radio Plug-in for MythTV
  • An audio stream capture how-to

What you need to have

Setup

  • You only need to have an account setup at Sirius.com.

Installed

Required:

Optional:

Introducing SIPIE

Pronounced SY PIE, like sirius python

sipie is a command line player for sirius on-line Internet streaming. It requires a login to sirius's streaming, both
guest and subscriber logins are supported. Streams are entered on the command line or are asked for. TAB twice will 
list all streams, type part of a stream and hit TAB to complete it.  You can change streams without restarting 
(and thus not re-authenticating) by hitting CTRL-C while a stream is playing.

sipie is written in python, and uses mplayer for the streams. Beautiful Soup is the only extra library you'll need. 
See the README on how to get it.

Eli Criffield

Let's get started!

Installing SIPIE

The README is extremely simple to understand and only takes a few minutes to get up and running... I suggest using that as a guide because ONLY when you get sipie working OUTSIDE of MythTV, will it work INSIDE of MythTV. Also, make sure when you do your sipie setup that you do it under your mythtv account (or whatever account runs the front end).

Installing Beautiful Soup

Gabe says he has some issues getting Beautiful Soup to install, so he ran these commands to get it working. I didn't have to do this so I couldn't verify, but we'll take his word.

# cd /usr/bin
# wget http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py

Installing VIA YUM

You should only need the extras repository to install... This was my install. Make sure this is done in your GUI or you won't be able to see the captcha (not unless you have asciiviewer installed, then you can use a ssh session).

#yum install python python-setuptools wxPython

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 wxPython                i386       2.6.3.2-2.fc6    extras            7.4 M
Installing for dependencies:
 wxGTK                   i386       2.6.3-2.6.3.2.3.fc6  extras            3.5 M
 wxGTK-gl                i386       2.6.3-2.6.3.2.3.fc6  extras             28 k

Transaction Summary
=============================================================================
Install      3 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 11 M
<snip>
Completed!

# easy_install BeautifulSoup

# cd /usr/bin
# wget http://eli.criffield.net/sipie/sipie
# chmod a+x sipie

$ sipie

username and a crypted password will be stored in ~/.sipie/config
no plain text passwords are stored
if you want to change your password remove ~/.sipie/config
then run sipie and it'll ask you for username and password again

Enter username: MySiriusUsername
Enter password:

Login Type, type guest or subscriber
Enter login type: subscriber

After that last prompt I was shown the captcha and I entered the code correctly. Also note that (at least in my case) I only had to enter the text from the captcha during initial setup and never once again since (it's been weeks). Then, I was prompted to select a station so I did and I could hear the stream... It doesn't matter if it prompts you to enter a station from a GUI drop-down or from the command line... later in the article we'll force it to run with no user input.

Installing VIA APT

Read the README for sipie

Installing on Ubuntu

Read the README for sipie

Tweak the config

Now, we need to make some changes to the sipie config file to shut-off the stream GUI and adjust the song display settings. You will want to change the mythtv user in the path below to whatever account your MythTV front end uses.

#vi /home/mythtv/.sipie/config

Inside the config file you will want to change the "trygui" to False to disable the stream selection GUI.

trygui = False

Optionally, you can tweak the "showplaying" tag to True if you want it to overlay the MythTV window (small box on the bottom right corner) each time the song changes and spit the song name back to your open command window if you ran the sipie script from one. If you don't want the song name to overlay the window just set it to False.

showplaying = True

Song Overlay Requirements

If you want to see the song name overlay make sure you have the following installed on your system:

  • notify-python (Fedora extras)
  • dbus-x11 (Fedora updates)

One of my frontends already had dbus-x11 installed, but the other didn't... either way, I got both of them on my FC6 system's by using yum but your distro may be different.

Make sure it works

Now that you have read the README for sipie and can listen to streams, we can tweak some command and then integrate it with our MythTV instance.

Let's hack it together

OK, now we are going to write a couple of uber-simple shell scripts that we will use to make MythTV happy while talking to sipie. You will notice that these are simple, novice scripts that are pretty ruthless in how they work... plus sipie doesn't have an API and isn't intended for applications such as this... I haven't been calling it a "hack" the whole time for nothing. :-)

Create files

We need to create a couple of files so find a nice place you can create and execute them from. Personally, I put them in /usr/bin, the same place I put sipie.

# vi sipie_myth
#!/bin/bash
# Control Sirius in Myth

if [ "$1" != "" ]; then
        # First, we'll kill off any other stream that may be playing
        /usr/bin/sipie_kill
        echo "I'm about to play:" $1
        /usr/bin/$1 &
else
        exit 1
fi
exit 0
# vi sipie_kill
#!/bin/bash
# Kill sipie from Myth

pkill -f sirius.com/sirius/mediaplayer/
killall python

Or, in the event you're a Canadian Sirius subscriber use this sipie_kill script (yes I could automate this but I'm lazy

#!/bin/bash
# Kill sipie from Myth

pkill -f '/sirius/ca/mediaplayer/'
killall python

Now you will want to make them both executable:

# chmod a+x sipie_*

Important note: A simple glance at sipie_kill shows you that it murders all running python processes in order to handle a single one of them (kinda like O.J. did), that's hard-core overkill and can cause serious problems if you run other python processes. I personally run no other python instances when my MythTV GUI is up and running so it's no big deal for me. You will can check that for your case by running the following command (while sipie is NOT running)

$ ps -C python
  PID TTY          TIME CMD

That shows me that I am not running anything that sipie_kill will destroy when I change Sirius streams from with-in MythTV. Here is what the same command looks like when you're listening to a stream of have another python process running.

$ ps -C python
  PID TTY          TIME CMD
 4702 ?        00:00:00 python

If you see other important python process running then you'll have to come up with something better then "killall python" and put it in the sipie_kill script or else you'll spawn a new process every time you change a stream. Granted, removing that line will not cause any immediate problems as it will still kill the mplayer stream and stop the music, but it will keep stacking sipie python processes, which is not a good thing. I'm sure it's not hard to simply add a few lines to the scripts that would pass pid's between them and target only the python sipie process but that's for a later revision of this process. If you come up with a mod to this script, please refine this article.

Create the soft links

Next, we want to create those links that you read about at the end of the README file earlier (you did read it didn't you?). We have to create these links because the sipie_myth wrapper expects them to exist. My girlfriend and I don't listen to more then 4 or 5 stations online so I only added a few to my setup, but you can add as many as you like. I did it like this:

# cd /usr/bin
# ln -s sipie howardstern100
# ln -s sipie octane
# ln -s sipie altnation
# ln -s sipie hardattack
# ln -s sipie siriusnflradio
# ln -s sipie 90salternative

Test scripts

Now, pull up a command window and run one of the commands we just "made"

$ octane

Do you hear the stream without having to enter a single thing in the command window? That's good, now use this to kill the stream

$ sipie_kill

Did you have to enter information? That's bad. Make sure you setup sipie as your mythtv user and try again. Also make sure you created all of the soft links Integrate Sirius#Create_the_soft_links you want to use.

Setting up the MythTV GUI

At this point, you should be able to listen to (and kill) streams from the command line with no user intervention... that's 1/2 the battle. Now, we are going to hack a couple of buttons onto the default menu theme.

  • Note: If you are currently running .20+ chances are that you're using the default menu theme. No, NOT the actual MythTV theme, just the menu theme. To check out which one you're using do this in Myth: Utilities / Setup (or Setup) -> Appearance -> bottom of the first options page you will see the menu themes section, we will be hacking into "Default" so make sure it's set to that one, but if you use classic or DVR you can change some of the commands below so that your work is being done on that particular theme (just add /themes/classic or /themes/DVR respectively to the "cd" commands below) Since this is technically a hack you are expected to do some work to get it exactly the way you want it.

Backup the default theme

# cd /usr/share/mythtv
# tar cfvz default_backup.tar.gz *.xml

I use the v option because it's an easy way to verify (VIA verbose) what files were put into the tar ball.

Hack the default theme

I'm only going to show you the 2 required changes to get this hack to work.

I added the following to my mainmenu.xml file.

# cd /usr/share/mythtv
# vi mainmenu.xml
   <button>
      <type>MUSIC</type>
      <text>Play Sirius Radio</text>
      <action>MENU siriusmenu.xml</action>
   </button>

Then, I created the siriusmenu.xml file (be sure to add all of the streams you want access to):

# vi siriusmenu.xml
<mythmenu name="SIRIUS">

   <button>
      <type>MUSIC</type>
      <text>Howard 100</text>
      <action>EXEC /usr/bin/sipie_myth howardstern100</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Octane</text>
      <action>EXEC /usr/bin/sipie_myth octane</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Alt Nation</text>
      <action>EXEC /usr/bin/sipie_myth altnation</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Super Shuffle</text>
      <action>EXEC /usr/bin/sipie_myth supershuffle</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Big 80s</text>
      <action>EXEC /usr/bin/sipie_myth big80s</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Lithium</text>
      <action>EXEC /usr/bin/sipie_myth 90salternative</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Sirius Hits 1</text>
      <action>EXEC /usr/bin/sipie_myth siriushits1</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Coffee House</text>
      <action>EXEC /usr/bin/sipie_myth coffeehouse</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>NFL Radio</text>
      <action>EXEC /usr/bin/sipie_myth siriusnflradio</action>
   </button>

   <button>
      <type>TV_DELETE</type>
      <text>Stop Listening</text>
      <action>EXEC /usr/bin/sipie_kill</action>
   </button>

</mythmenu>

Tag definitions

OK, now the tag definitions for the above xml file

  • "button" tells the theme to paint a button on the screen
  • "type" tells the theme what image to use for the button
  • "text" tells MythTV what button text to put on the screen
  • "action" tells MythTV what to do when you select the button

Why it works

You have to wrap sipie_myth around the stream because when MythTV runs the EXEC it waits for a response before it releases the button. sipie_myth simply kicks off the stream and tells MythTV that it's finished executing. You are going to have to modify this file if you want to add another language tag or if you want to add additional channels, it should be simple to see what needs done to make it work just be sure that you create the soft links before you try to add a button or it won't play the stream.

Additional Setup and Usage Notes

  1. Be patient after you choose a stream as sometimes it will take 30 - 45 seconds to start playing
  2. The stream will play until you choose the "Stop Listening" button on the GUI (or the sipie_kill script is executed)
  3. When you're listening to a stream, it locks up the audio output device for MythTV which can be good and it can be bad, see below.
GOOD
  • If you want to watch a Football game on TV and listen to the commentators from Sirius instead of the TV commentators
  • If for some strange reason you want to actually listen to music and watch MTV instead of listening to the crappy reality shows they play 21x7
BAD
  • If you wanted to play 2 audio streams at once to make your own mix tapes. ;-)

Screen shots

The new default main menu: Main Menu

The Sirius stream selection menu: Sirius Menu