Difference between revisions of "Integrate Sirius"

From MythTV Official Wiki
Jump to: navigation, search
(Create files: Changed scripts to keep track of the player PID and not to use the "killall" hammer)
m (Installing pyxis)
 
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This article is going to give you all of the info you need in order to pipe your online [http://www.sirius.com/ 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.
+
This article is going to give you all of the info you need in order to pipe your online [http://www.sirius.com/ 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 should be EASILY adapted to any distro. Please, '''READ THE ENTIRE ARTICLE CAREFULLY''' all the way to the end before you start anything.
  
 
{{Note box|this is NOT a plug-in and is basically a hack but when completed it looks just like a plug-in.}}
 
{{Note box|this is NOT a plug-in and is basically a hack but when completed it looks just like a plug-in.}}
 +
{{Note box|article has been significantly updated to replace Sipie with Pyxis.  Pyxis is more robust including recording capabilities.}}
  
  
Line 16: Line 17:
 
*How-To perfectly integrate with your particular MythTV GUI (we only cover the default menu theme)
 
*How-To perfectly integrate with your particular MythTV GUI (we only cover the default menu theme)
 
*A Sirius Radio Plug-in for MythTV
 
*A Sirius Radio Plug-in for MythTV
*An audio stream capture how-to
 
  
 
==What you need to have==
 
==What you need to have==
Line 25: Line 25:
 
Required:
 
Required:
 
*[http://www.mythtv.org MythTV]
 
*[http://www.mythtv.org MythTV]
*[http://python.org Python] (2.4+)
+
*[http://python.org Python] (2.5+)
 
*[http://www.mplayerhq.hu/ mplayer]
 
*[http://www.mplayerhq.hu/ mplayer]
*[http://freshmeat.net/projects/sipie/?branch_id=67224 sipie]
+
*[http://ionshard.com/pyxis pyxis] (Instructions below)
*[http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup]
+
*[http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup] (instructions also below)
  
 
Optional:
 
Optional:
 
*[http://www.wxpython.org/ wxPython]
 
*[http://www.wxpython.org/ wxPython]
*[http://www.google.com/search?sourceid=navclient-ff&ie=UTF-8&rlz=1B2GGIC_enUS209US209&q=python-notify python-notify]
+
*[http://www.google.com/search?sourceid=navclient-ff&ie=UTF-8&rlz=1B2GGIC_enUS209US209&q=python-notify python-notify] (highly recommended)
  
==Introducing SIPIE==
+
==Introducing PYXIS==
 
<pre>
 
<pre>
Pronounced SY PIE, like sirius python
+
A Command Line Player for SIRIUS and XM Satellite Radio
 +
Pyxis is a wrapper that provides access to SIRIUS’ internet radio streams through the command line.
 +
Pyxis is written entirely in python.
 +
Pyxis is a large rewrite of the original project Sipie written and maintained by Eli Criffield at
 +
http://sipie.sourceforge.net/ and none of Pyxis would have been possible without Sipie’s
 +
authentication code. Big thank you to Eli Criffield.
  
sipie is a command line player for sirius on-line Internet streaming. It requires a login to sirius's streaming, both
+
The reason for Pyxis’s existence is because in recent years development on Sipie has slowed
guest and subscriber logins are supported. Streams are entered on the command line or are asked for. TAB twice will
+
and as such when SIRIUS changes something the time required to bring it back to a working
list all streams, type part of a stream and hit TAB to complete it.  You can change streams without restarting
+
version can sometimes be a long time.  
(and thus not re-authenticating) by hitting CTRL-C while a stream is playing.
+
So a couple of us decided to rip out all the largely unused portions of Sipie, refactor a lot of  
 
+
it and bring it into a more stable and adaptable package. Thus Pyxis was born when we realized
sipie is written in python, and uses mplayer for the streams. Beautiful Soup is the only extra library you'll need.  
+
we could no longer pretend it was still Sipie.
See the README on how to get it.
 
 
 
Eli Criffield
 
 
</pre>
 
</pre>
  
 
==Let's get started!==
 
==Let's get started!==
===Installing SIPIE===
+
===Installing pyxis Requirements===
[http://eli.criffield.net/sipie/sipie_README 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).
+
TwoOneSix wrote a script for sipie (sipie_myth) that is for usage in MythTV.  This script has been modified (below) to work with pyxis. Remember that ONLY when you get pyxis working OUTSIDE of MythTV, will it work INSIDE of MythTV. Also, make sure when you do your initial pyxis '''setup''' that you do it under your mythtv account (or whatever account runs the front end).
 +
 
  
===Installing Beautiful Soup===
+
====Installing pyxis====
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.
+
This is from [http://ionshard.com/pyxis]
 
<pre>
 
<pre>
# cd /usr/bin
+
sudo add-apt-repository ppa:pyxis/pyxis
# wget http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py
+
sudo apt-get update
 +
sudo apt-get install pyxis
 
</pre>
 
</pre>
  
===Installing VIA YUM===
+
Note: Should you already have python-setuptools, you ''may'' have to remove first with:
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).''
 
 
<pre>
 
<pre>
#yum install python python-setuptools wxPython
+
sudo apt-get remove python-setuptools
 
 
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
 
 
</pre>
 
</pre>
  
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 Beautiful Soup====
 
+
Current version of BeautifulSoup will now generate a stack trace.  Appears to be reported as a bug in BeautifulSoup [https://bugs.launchpad.net/beautifulsoup/+bug/403640] Sirius.com doesn't put quotes around one style tag and BeautifulSoup crashes.
===Installing VIA APT===
 
[http://eli.criffield.net/sipie/sipie_README Read the README for sipie]
 
  
===Installing on Ubuntu===
+
3.0.7 still works for Sipie so use the following.:
[http://eli.criffield.net/sipie/sipie_README 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.
 
 
<pre>
 
<pre>
#vi /home/mythtv/.sipie/config
+
# cd ~
 +
# wget http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.0.7.tar.gz
 +
# tar xvf BeautifulSoup-3.0.7.tar.gz
 +
# cd BeautifulSoup-3.0.7
 +
# sudo easy_intall .
 
</pre>
 
</pre>
  
Inside the config file you will want to change the "trygui" to False to disable the stream selection GUI.
+
 
 +
===Configuring pyxis===
 +
You need to ensure that the configuration is done under the same user account that MythTV runs under, in my case it's the '''mythtv''' user, simple enough. Select the options for your configuration:
 
<pre>
 
<pre>
trygui = False
+
$ cd ~
</pre>
+
$ pyxis
  
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.
+
Welcome to Pyxis Setup
*sipie uses http://www.dogstarradio.com for the song names which works just fine. I personally prefer http://www.itsonsirius.net.
 
<pre>
 
showplaying = True
 
</pre>
 
  
'''Song Overlay Requirements'''
+
Your username and an encrypted password will be stored in /home/[username]/.config/pyxis/pyxisrc
 +
You can rerun setup anytime by running: pyxis --setup
  
If you want to see the song name overlay make sure you have the following installed on your system:
+
Enter username: yourUserName
*notify-python (Fedora extras)
+
Enter password: yourPassword
*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.
+
Please answer the following questions, pressing enter will accept the default values shown in bold text.
  
===Make sure it works===
+
Enter Login Type (guest or subscriber)
Now that you have read the [http://eli.criffield.net/sipie/sipie_README README] for sipie and can listen to streams, we can tweak some command and then integrate it with our MythTV instance.
+
Login type: subscriber
  
==Let's hack it together==
+
Are you using Sirius Cananda (True or False)
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. :-)
+
http://siriuscanada.ca: False
  
===Create files===
+
Select bitrate (High or Low): High
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.
 
<pre>
 
# vi sipie_myth
 
 
</pre>
 
</pre>
<pre>
 
#!/bin/bash
 
# Control Sirius in Myth
 
  
pid_file=/tmp/sipie_myth.pid
+
*Stop the stream with Ctrl+C.
  
if [ "$1" != "" ]; then
+
==Let's hack it together==
        # First, we'll kill off any other stream that may be playing
+
OK, now we are going to write a simple shell script that we will use to make MythTV happy while talking to sipie.
        /usr/bin/sipie_kill
 
        echo "I'm about to play:" $1
 
        /usr/bin/$1 &
 
        echo `ps -p %1` > $pid_file
 
else
 
        exit 1
 
fi
 
exit 0
 
</pre>
 
  
 +
====Create pyxis_myth====
 +
We need to create a single executable file so find a nice place you can execute it from. Personally, I use ''/usr/bin''. You can replace ''vi'' with ''gedit'' or ''kedit'' if you prefer a GUI text editor.
 
<pre>
 
<pre>
# vi sipie_kill
+
# vi /usr/bin/pyxis_myth
 
</pre>
 
</pre>
 +
 +
Now, paste in the following code:
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
# Kill sipie from Myth
+
# Script By: Josh <TwoOneSix AT thatclothingco DOT com>
 +
# revised to work with pyxis by Eric <eric DOT dreher AT gmail DOT com>
 +
# Used to control pyxis (Sirius radio player) from MythTV menu
  
pid_file=/tmp/sipie_myth.pid
+
pid_file=/tmp/pyxis_myth.pid
  
if [[ -f $pid_file ]]
+
# find and kill all the child processes
then
+
killtree() {
         kill `cat $pid_file`
+
    local _pid=$1
         rm $pid_file
+
    local _sig=${2-TERM}
fi
+
    for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
</pre>
+
        killtree ${_child} ${_sig}
 +
    done
 +
    kill -${_sig} ${_pid}
 +
}
 +
 
 +
# stop it all
 +
die_mythPyxis()
 +
{
 +
         killtree `cat $pid_file`
 +
         rm -f $pid_file
 +
        return 0
 +
}
  
Now you will want to make them both executable:
+
#begin to play a stream
<pre>
+
play_mythPyxis()
# chmod a+x sipie_*
+
{
</pre>
+
        stream="$*"
 +
        echo "I'm about to play: $stream"
 +
        exec /usr/bin/pyxis "$stream" &
 +
        echo $! > $pid_file
 +
        return 0
 +
}
  
You will can check that for your case by running the following command (while sipie is NOT running).
+
# If we see the kill command, kill the old processes/streams
<pre>
+
if [ "$1" = "kill" ]; then
$ ps -C python
+
        die_mythPyxis
  PID TTY          TIME CMD
 
</pre>
 
  
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.
+
# If we see the play command, kill any existing streams then play the stream
<pre>
+
elif [ "$1" = "play" ] && [ "$2" != "" ]; then
$ ps -C python
+
        if [ ! -e $pid_file ] ; then
  PID TTY         TIME CMD
+
                play_mythPyxis $2
4702 ?        00:00:00 python
+
        else
 +
                die_mythPyxis
 +
                # Just to be sure it's gone...
 +
                if [ ! -e $pid_file ] ; then
 +
                        play_mythPyxis $2
 +
                else
 +
                        echo 1>&2 '******FATAL ERROR STARTING STREAM PLAY******'
 +
                        exit 1
 +
                fi
 +
        fi
 +
        exit 0
 +
else
 +
        echo 1>&2 'Usage: ' $0 '{kill | play} stream (stream only required on play)'
 +
         exit 127
 +
fi
 
</pre>
 
</pre>
  
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.
+
Now you will want to make the file executable:
 
 
===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:
 
 
<pre>
 
<pre>
# cd /usr/bin
+
# chmod a+x /usr/bin/pyxis_myth
# ln -s sipie howardstern100
 
# ln -s sipie octane
 
# ln -s sipie altnation
 
# ln -s sipie hardattack
 
# ln -s sipie siriusnflradio
 
# ln -s sipie 90salternative
 
 
</pre>
 
</pre>
  
 
===Test scripts===
 
===Test scripts===
Now, pull up a command window and run one of the commands we just "made"
+
Now, as your mythtv user, pull up a command window and run the command we just "made" with the stream to test.
 +
*Usage:  /usr/bin/pyxis_myth {kill | play} stream (stream only required on play)
 
<pre>
 
<pre>
$ octane
+
$ pyxis_myth play octane
 
</pre>
 
</pre>
  
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
+
Do you hear the stream without having to enter a single thing in the command window? Do you see the song names in the command window and in the pop-up notifier (if you left tryPopus=True)? That's good, now use this to kill the stream:
 
<pre>
 
<pre>
$ sipie_kill
+
$ pyxis_myth kill
 
</pre>
 
</pre>
  
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.
+
Did you have to enter information? That's bad. [[Integrate Sirius#Configuring_Sipie | Make sure you configured pyxis as your mythtv user]] and try again.
 +
 
  
 
==Setting up the MythTV GUI==
 
==Setting up the MythTV GUI==
Line 240: Line 211:
 
# tar cfvz default_backup.tar.gz *.xml
 
# tar cfvz default_backup.tar.gz *.xml
 
</pre>
 
</pre>
I use the v option because it's an easy way to verify (VIA verbose) what files were put into the tar ball.
+
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===
 
===Hack the default theme===
 
I'm only going to show you the 2 required changes to get this hack to work.
 
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.
+
{{Note box|If you're running a MythDora release these files might be located in a different directory.}}
 +
 
 +
Now, add the following to mainmenu.xml file.
 
<pre>
 
<pre>
 
# cd /usr/share/mythtv
 
# cd /usr/share/mythtv
Line 258: Line 231:
 
</pre>
 
</pre>
  
Then, I created the siriusmenu.xml file (be sure to add all of the streams you want access to):
+
Then, create the siriusmenu.xml file (be sure to add all of the streams you want access to).  Run pyxis from the command line and enter "list" to get a current channel listing.  A few current channels are included as an example.  Add as many as you want, but the more you add the further the "Stop" command is to navigate to.
 
<pre>
 
<pre>
 
# vi siriusmenu.xml
 
# vi siriusmenu.xml
Line 267: Line 240:
 
   <button>
 
   <button>
 
       <type>MUSIC</type>
 
       <type>MUSIC</type>
       <text>Howard 100</text>
+
       <text>80s On 8</text>
       <action>EXEC /usr/bin/sipie_myth howardstern100</action>
+
       <action>EXEC /usr/bin/pyxis_myth play "80s On 8"</action>
 
   </button>
 
   </button>
  
Line 274: Line 247:
 
       <type>MUSIC</type>
 
       <type>MUSIC</type>
 
       <text>Octane</text>
 
       <text>Octane</text>
       <action>EXEC /usr/bin/sipie_myth octane</action>
+
       <action>EXEC /usr/bin/pyxis_myth play Octane</action>
  </button>
 
 
 
  <button>
 
      <type>MUSIC</type>
 
      <text>Alt Nation</text>
 
      <action>EXEC /usr/bin/sipie_myth altnation</action>
 
 
   </button>
 
   </button>
  
 
   <button>
 
   <button>
 
       <type>MUSIC</type>
 
       <type>MUSIC</type>
       <text>Super Shuffle</text>
+
       <text>The Bridge</text>
       <action>EXEC /usr/bin/sipie_myth supershuffle</action>
+
       <action>EXEC /usr/bin/pyxis_myth play "The Bridge"</action>
 
   </button>
 
   </button>
  
 
   <button>
 
   <button>
 
       <type>MUSIC</type>
 
       <type>MUSIC</type>
       <text>Big 80s</text>
+
       <text>Outlaw Country</text>
       <action>EXEC /usr/bin/sipie_myth big80s</action>
+
       <action>EXEC /usr/bin/pyxis_myth play "Outlaw Country"</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>
  
Line 322: Line 265:
 
       <type>TV_DELETE</type>
 
       <type>TV_DELETE</type>
 
       <text>Stop Listening</text>
 
       <text>Stop Listening</text>
       <action>EXEC /usr/bin/sipie_kill</action>
+
       <action>EXEC /usr/bin/pyxis_myth kill</action>
 
   </button>
 
   </button>
  
 
</mythmenu>
 
</mythmenu>
 
</pre>
 
</pre>
 +
  
 
===Tag definitions===
 
===Tag definitions===
Line 336: Line 280:
  
 
===Why it works===
 
===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.
+
You have to wrap pyxis_myth around the stream because when MythTV runs the EXEC it waits for a response before it releases the button. pyxis_myth simply kicks off the stream and tells MythTV that it's finished executing. You are going to have to modify the XML menu files if you want to add another language tag or if you want to add additional channels.
  
 
==Additional Setup and Usage Notes==
 
==Additional Setup and Usage Notes==
 
#Be patient after you choose a stream as sometimes it will take 30 - 45 seconds to start playing
 
#Be patient after you choose a stream as sometimes it will take 30 - 45 seconds to start playing
#The stream will play until you choose the "Stop Listening" button on the GUI (or the sipie_kill script is executed)
+
#The stream will play until you choose the "Stop Listening" button on the GUI (or ''pyxis_myth kill'' is executed)
 
#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.
 
#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'''
 
:'''GOOD'''
 
::*If you want to watch a Football game on TV and listen to the commentators from Sirius instead of the TV commentators
 
::*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'''
 
:'''BAD'''
 
::*If you wanted to play 2 audio streams at once to make your own mix tapes. ;-)
 
::*If you wanted to play 2 audio streams at once to make your own mix tapes. ;-)
Line 350: Line 293:
 
==Screen shots==
 
==Screen shots==
 
The new default main menu:
 
The new default main menu:
[[Image:Sirius_mainmenu.png|Main Menu]]
+
[[Image:Sirius_mainmenu.png|Main Menu| 360x240px]]
  
 
The Sirius stream selection menu:
 
The Sirius stream selection menu:
[[Image:Sirius_siriusmenu.png|Sirius Menu]]
+
[[Image:Sirius_siriusmenu.png|Sirius Menu| 360x240px]]
 
 
Showing the song name in a pop-up:
 
[[Image:Sirius_popupmenu.png|Sirius song name pop-up]]
 
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Latest revision as of 18:26, 4 July 2012

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 should 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.

Important.png Note: article has been significantly updated to replace Sipie with Pyxis. Pyxis is more robust including recording capabilities.


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

What you need to have

Setup

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

Installed

Required:

Optional:

Introducing PYXIS

A Command Line Player for SIRIUS and XM Satellite Radio
Pyxis is a wrapper that provides access to SIRIUS’ internet radio streams through the command line. 
Pyxis is written entirely in python.
Pyxis is a large rewrite of the original project Sipie written and maintained by Eli Criffield at 
http://sipie.sourceforge.net/ and none of Pyxis would have been possible without Sipie’s 
authentication code. Big thank you to Eli Criffield.

The reason for Pyxis’s existence is because in recent years development on Sipie has slowed 
and as such when SIRIUS changes something the time required to bring it back to a working 
version can sometimes be a long time. 
So a couple of us decided to rip out all the largely unused portions of Sipie, refactor a lot of 
it and bring it into a more stable and adaptable package. Thus Pyxis was born when we realized 
we could no longer pretend it was still Sipie.

Let's get started!

Installing pyxis Requirements

TwoOneSix wrote a script for sipie (sipie_myth) that is for usage in MythTV. This script has been modified (below) to work with pyxis. Remember that ONLY when you get pyxis working OUTSIDE of MythTV, will it work INSIDE of MythTV. Also, make sure when you do your initial pyxis setup that you do it under your mythtv account (or whatever account runs the front end).


Installing pyxis

This is from [1]

sudo add-apt-repository ppa:pyxis/pyxis
sudo apt-get update
sudo apt-get install pyxis

Note: Should you already have python-setuptools, you may have to remove first with:

sudo apt-get remove python-setuptools

Installing Beautiful Soup

Current version of BeautifulSoup will now generate a stack trace. Appears to be reported as a bug in BeautifulSoup [2] Sirius.com doesn't put quotes around one style tag and BeautifulSoup crashes.

3.0.7 still works for Sipie so use the following.:

# cd ~
# wget http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.0.7.tar.gz
# tar xvf BeautifulSoup-3.0.7.tar.gz
# cd BeautifulSoup-3.0.7
# sudo easy_intall .


Configuring pyxis

You need to ensure that the configuration is done under the same user account that MythTV runs under, in my case it's the mythtv user, simple enough. Select the options for your configuration:

$ cd ~
$ pyxis

Welcome to Pyxis Setup

Your username and an encrypted password will be stored in /home/[username]/.config/pyxis/pyxisrc
You can rerun setup anytime by running: pyxis --setup

Enter username: yourUserName
Enter password: yourPassword

Please answer the following questions, pressing enter will accept the default values shown in bold text.

Enter Login Type (guest or subscriber)
Login type: subscriber

Are you using Sirius Cananda (True or False)
http://siriuscanada.ca: False

Select bitrate (High or Low): High
  • Stop the stream with Ctrl+C.

Let's hack it together

OK, now we are going to write a simple shell script that we will use to make MythTV happy while talking to sipie.

Create pyxis_myth

We need to create a single executable file so find a nice place you can execute it from. Personally, I use /usr/bin. You can replace vi with gedit or kedit if you prefer a GUI text editor.

# vi /usr/bin/pyxis_myth

Now, paste in the following code:

#!/bin/bash
# Script By: Josh <TwoOneSix AT thatclothingco DOT com>
# revised to work with pyxis by Eric <eric DOT dreher AT gmail DOT com>
# Used to control pyxis (Sirius radio player) from MythTV menu

pid_file=/tmp/pyxis_myth.pid

# find and kill all the child processes 
killtree() {
    local _pid=$1
    local _sig=${2-TERM}
    for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
        killtree ${_child} ${_sig}
    done
    kill -${_sig} ${_pid}
}

# stop it all
die_mythPyxis()
{
        killtree `cat $pid_file`
        rm -f $pid_file
        return 0
}

#begin to play a stream
play_mythPyxis()
{
        stream="$*"
        echo "I'm about to play: $stream"
        exec /usr/bin/pyxis "$stream" &
        echo $! > $pid_file
        return 0
}

# If we see the kill command, kill the old processes/streams
if [ "$1" = "kill" ]; then
        die_mythPyxis

# If we see the play command, kill any existing streams then play the stream
elif [ "$1" = "play" ] && [ "$2" != "" ]; then
        if [ ! -e $pid_file ] ; then
                play_mythPyxis $2
        else
                die_mythPyxis
                # Just to be sure it's gone...
                if [ ! -e $pid_file ] ; then
                        play_mythPyxis $2
                else
                        echo 1>&2 '******FATAL ERROR STARTING STREAM PLAY******'
                        exit 1
                fi
        fi
        exit 0
else
         echo 1>&2 'Usage: ' $0 '{kill | play} stream (stream only required on play)'
         exit 127
fi

Now you will want to make the file executable:

# chmod a+x /usr/bin/pyxis_myth

Test scripts

Now, as your mythtv user, pull up a command window and run the command we just "made" with the stream to test.

  • Usage: /usr/bin/pyxis_myth {kill | play} stream (stream only required on play)
$ pyxis_myth play octane

Do you hear the stream without having to enter a single thing in the command window? Do you see the song names in the command window and in the pop-up notifier (if you left tryPopus=True)? That's good, now use this to kill the stream:

$ pyxis_myth kill

Did you have to enter information? That's bad. Make sure you configured pyxis as your mythtv user and try again.


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.


Important.png 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) -> Setup -> Appearance -> and at the bottom of the first options page you will see the menu themes selection box, we will be hacking into "Default" so make sure it's set to that one. 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).

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.


Important.png Note: If you're running a MythDora release these files might be located in a different directory.

Now, add the following to 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, create the siriusmenu.xml file (be sure to add all of the streams you want access to). Run pyxis from the command line and enter "list" to get a current channel listing. A few current channels are included as an example. Add as many as you want, but the more you add the further the "Stop" command is to navigate to.

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

   <button>
      <type>MUSIC</type>
      <text>80s On 8</text>
      <action>EXEC /usr/bin/pyxis_myth play "80s On 8"</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Octane</text>
      <action>EXEC /usr/bin/pyxis_myth play Octane</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>The Bridge</text>
      <action>EXEC /usr/bin/pyxis_myth play "The Bridge"</action>
   </button>

   <button>
      <type>MUSIC</type>
      <text>Outlaw Country</text>
      <action>EXEC /usr/bin/pyxis_myth play "Outlaw Country"</action>
   </button>

   <button>
      <type>TV_DELETE</type>
      <text>Stop Listening</text>
      <action>EXEC /usr/bin/pyxis_myth 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 pyxis_myth around the stream because when MythTV runs the EXEC it waits for a response before it releases the button. pyxis_myth simply kicks off the stream and tells MythTV that it's finished executing. You are going to have to modify the XML menu files if you want to add another language tag or if you want to add additional channels.

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 pyxis_myth kill 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
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