In the UK there are several radio stations available via FreeView. The stations are broadcast as dvb streams and may be recorded using MythTV. However, Myth stores the channels in mpeg format, which won’t play on many mp3 players. Also it’s not straightforward getting the file from MythTV onto your player. It is possible to use Justin Hornsby’s excellent dvbradioexport.pl to export recordings in mp3 format, but I wanted to create an rss feed for my recordings too. Rather than try to change dvbradioexport.pl, I rewrote it in Python with some minor tweaks that allow my script to call another script which creates the rss podcast feed.
The process is:
- Run dvbradioexport.py to convert the Myth mpeg files for the dvb radio recording into mp3 format.
- Automatically update my rss feed each time I export a new recording by running myth_dvbpodcast.py.
dvbradioexport.py has the option of running myth_dvbpodcast.py to automate the whole process by using a User Job. However, you can run either script separately. This makes it possible to create an rss feed from a pre-existing directory of mp3 files.
Prerequisites.
- Python > V2.3.
- The eyeD3 python library. In Ubuntu you can install this by running:
sudo apt-get install python-eyed3
- MythTV compiled with the Python bindings (run ./configure with —bindings=python). In Ubuntu the python bindings can be installed separately by running:
sudo apt-get install libmyth-python
- A webserver for the podcast feed.
Installation.
- Unpack the archive:
tar -xvzf myth_dvbpodcast.tgz
- Change to the directory where you unpacked the files:
cd ~/devel/myth_dvbpodcast
- Make sure that all the python files are executable:
chmod o+x *.py
- Change the ownership of the files so they can be run by the mythtv user.
sudo chown mythtv.users *.py
- Copy the files to a directory where they can be run my mythtv.
sudo cp *.py /usr/local/bin
- Edit the configuration options in myth_dvbpodcast.py and dvbradioexport.py.
- Create a directory to hold the podcasts. This directory must be readable
by the wbeserver and writeable by the mythtv user.
- Set up a User Job in Myth to run dvbexport.py.
/usr/bin/nice -19 /home/ian/devel/python_podcast/dvbradioexport.py \ exportdir=/media/recordings/mythtv/radio/ \ starttime=%STARTTIME% chanid=%CHANID% maxbitrate=64
Note that the trailing backslash on exportdir is important.
Configuring the Webserver.
You need to make the directory where you store your podcasts accessible to Apache. To make podcasts available at http://www.roursite.com/podcasts/ you need to add a section similar to that below to your /etc/apache/sites-available/default. Don’t forget to restart Apache (sudo /etc/init.d/apache2 restart) to make your changes take effect.
Alias /podcasts/ "/media/recordings/mythtv/radio/"
<Directory "/media/recordings/mythtv/radio/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from all
</Directory>
Testing.
You can test your setup by running dvbradioexport.py from the command line:
./dvbradioexport.py --exportdir=/media/recordings/mythtv/radio --starttime=20080714092900 --chanid=1708 --maxbitrate=64
Note that you need to choose a starttime and chanid for one of your own recordings. Also the destination directory where the mp3 file is being created must be writeable by whatever user you are running the script as.
If you have set CREATE_FEED = True in dvbradioexport.py, the script should create a podcast.rss file in whatever directory you specified in RECORDINGS_DIR in mythdvb_podcast.py. You can view the feed in your web browser by navigating to the appropriate url:
http://www.mysite.com/podcasts/podcast.rss
You can also subscribe to this feed using your podcast client.
Limitations of the Script.
mythdvbradio_podcast.py will simply try and create an rss feed from whatever mp3 files are specified in RECORDINGS_DIR. If you delete or modify files you can re-create the feed by re-running mythdvbradio_podcast.py.
Download.
You can download the current version from the link below:
