Pretty much ever since I got KnoppMyth up and going, I've been wondering if there was a way that I could easily populate MythVideo with various shows found on the net, and MythMusic with podcasts and similar that I might enjoy listening to from the recliner. Originally, I used
Azureus with its RSS plugin to identify and download shows. Unfortunately, it isn't really flexible, not terribly scalable, required signifigant resources, and only worked with torrent feeds. Another solution was
Torrentocracy but that required manual intervention in order to download shows, so I never used it for more than testing.
Recently, I discovered that the podcasting client
iPodder can download more than just mp3s, and more importantly, that it can be used as a command line application. It is well known that it can download files directly and from torrents, and that it saves the files it gets in well organized directories. This is fairly ideal.
Armed with this information (and a lot of caffeine), this morning I set out to create the mythtv rss aggrigator of my dreams...
The end result of this project provides a way to periodically (via a crontab) download RSS based content into /myth/video and /myth/music. New feeds can be added by adding the rss feed information into a text file.
Before starting, make sure that you have wxpython installed on your system. It is a dependency of iPodder and does not come installed on with R5A16.
Code:
# apt-get update; apt-get install wxpython2.6-0
The first thing to do is install the iPodder software. Since it doesn't appear in Debian's apt-get repository, I grabbed the current copy from sourceforge and installed it into the default location (under /opt).
As root: wrote:
# cd
# wget
http://unc.dl.sourceforge.net/sourcefor ... .1.tar.bz2# tar -xjf iPodder-linux-2.1.tar.bz2
# cd iPodder-linux
# ./install.sh
Accept the defaults and iPodder will be installed in /opt/iPodder
As it comes, iPodder will dump all of the files it gets into one directory. Since we want iPodder to be able to store the downloads into two directories (/myth/video,/myth/music) we will need to tweak its source code a little bit in order to give us the flexibility we need.
The first thing to do is get rid of the default podcasts that are always loaded up when you start iPodder. We don't want the 'welcome' mp3s showing up in myth.
We will need to be root in order to make the following changes. Also, be aware that indentation is VERY important in the python language we will be editing. I don't know how to get this forum to display indents correctly, so just make sure that the code that you change/add is indented the same as code around the changes.
Edit
/opt/iPodder/gui/skin.py and look for the section of code that looks like:
/opt/iPodder/gui/skin.py wrote:
DEFAULT_SUBS = [('Default Channel', \
'http://radio.weblogs.com/0001014/categories/ipodderTestChannel/rss.xml'), \
('iPodder News', 'http://ipodder.sf.net/podcasts/ipodder-users.xml')]
and change that to:
/opt/iPodder/gui/skin.py wrote:
DEFAULT_SUBS = []
Now we need to add a few features to the command line version of iPodder. The next thing we do will add a command like option for choosing where the iPodder state file is stored.
Edit:
/opt/iPodder/ipodder/configuration.py and look for:
/opt/iPodder/ipodder/configuration.py wrote:
parser.add_option('-f', '--favorites',
dest = 'favorites_file',
action = 'store',
type = 'string',
default = None,
help = "Override: specify which favorites file to use")
and add a new block right below that that looks like:
/opt/iPodder/ipodder/configuration.py wrote:
parser.add_option('-s', '--statedb',
dest = 'state_db_file',
action = 'store',
type = 'string',
default = None,
help = "Override: specify which state_db file to use")
Just because the command line iPodder will allow us to pass in a parameter stating that we'd like to over-ride the the location of the state database doesn't mean it will actually do it. The next change in this same file will tell iPodder to allow the location of the state_db and the favorites_file to be overridable.
In the file, look for a section that starts off like:
/opt/iPodder/ipodder/configuration.py wrote:
configOptions = [
# ('key',default, exposed)
('appdata_dir', None, True),
Beneath this entry, add the following new items:
/opt/iPodder/ipodder/configuration.py wrote:
('favorites_file', None, True),
('state_db_file', None, True),
Now the last thing we need to do is allow these variables to actually be overridden. It turns out that with the way the code is written, even if you
specify different favorites file, iPodder will just use the defaults values anyway.
Therefore, in the same file, a little lower down look for these lines:
Code:
self.favorites_file = join(appdata, "favorites.txt")
self.state_db_file = join(appdata, "iPodder.db")
and change them to:
Code:
if self.favorites_file is None:
self.favorites_file = join(appdata, "favorites.txt")
if self.state_db_file is None:
self.state_db_file = join(appdata, "iPodder.db")
The indentation here is very important. the self.* lines listed should be indented from the new if self.* lines.
Save the file.
One last thing that was discovered is that the players.py file need to be set as world readable so issue this command to make that so:
Code:
# chmod 644 /opt/iPodder/ipodder/players.py
Now that we are done making changes to the iPodder source code, we are ready to try out our modification.
For the rest of this tutorial, change to the mythtv user:
Quote:
# su mythtv
$ cd
get iPodder to create a preference directory for us.
Quote:
$ python /opt/iPodder/iPodder.py
This will create the /home/mythtv/iPodderData directory that will contain preference data for iPodder for our mythtv user.
You may want to view the ipodder.cfg file in that directory and adjust some variables such as
max_scan_jobs and
max_download_jobs to suite your greedy needs.
Create a preference file called videofeeds.txt that contains urls of all of our video rss feeds, one per line. For example:
/home/mythtv/iPodderData/videofeeds.txt wrote:
Also create one for the music feeds. For example:
/home/mythtv/iPodderData/musicfeeds.txt wrote:
Test to see if these work by issuing the following commands:
Quote:
$ python /opt/iPodder/iPodder.py --favorites=/home/mythtv/iPodderData/videofeeds.txt --statedb=/home/mythtv/iPodderData/video.db --downloads=/myth/video
$ python /opt/iPodder/iPodder.py --favorites=/home/mythtv/iPodderData/musicfeeds.txt --statedb=/home/mythtv/iPodderData/music.db --downloads=/myth/music
If things are going well, you will have new directories with mp3s and xvids and such in /myth/video and /myth/music. To add new feeds, just reedit the preference files and put in the RSS urls at the end.
Now things are working well enough, we'll have cron schedule iPodder to run a couple of times a day so that it can fetch any new content that comes out. To do that we'll create a new script that will contain all of our iPodder commands. A script will allow us to serialize our iPodder commands so that two instances of iPodder won't run at the same time and try to listen on the same port.
Create a shell script in mythtv's home directory that looks like:
/home/mythtv/runipodder.sh wrote:
#!/bin/sh
#
# This file will sequentially run instances of iPodder
# This is needed because of conflicts with the bit torrent port.
python /opt/iPodder/iPodder.py --favorites=/home/mythtv/iPodderData/videofeeds.txt --statedb=/home/mythtv/iPodderData/video.db --downloads=/myth/video > /dev/null 2>&1
python /opt/iPodder/iPodder.py --favorites=/home/mythtv/iPodderData/musicfeeds.txt -statedb=/home/mythtv/iPodderData/music.db --downloads=/myth/music >> /dev/null 2>&1
If you want to log the results of the iPodder runs to a file, be sure to change /dev/null to the name of the log file.
Make the script executable with the following command:
Quote:
$ chmod 755 /home/mythtv/runipodder.sh
Now we just need to add it to the scheduling system. We'll have our new command execute at 2:00 am and again at 2:00 pm.
Quote:
$ crontab -e
Add this line to mythtv's crontab
Quote:
0 2,14 * * * /home/mythtv/runipodder.sh > /dev/null 2>&1
That's it! The new content will appear automagically with it is released.
That said, there are some things to do to make this solution more useful.
The first thing would be to change the default view of MythVideo entries to "Listings". This will make browsing videos by directory possible in MythVideo. The setting is in:
Utilities/Setup->Setup->Media Settings->Videos Settings->General Settings->Default View.
Another thing to do in the same area is to turn off "Show Unknown File Types" as otherwise we will see a lot of .torrent files in MythVideo.
Setting "Video List browses files" on the same screen is useful because this will allow the new content to show up automatically when browsing MythVideo instead of having to wait for it to be manually scanned in like normal.
If you add quicktime feeds, or other feeds that the default mplayer doesn't know how to play, just follow the instructions on
this page to build a more functional mplayer that can play those media types.
If you do download more exotic media like quicktimes, you'll want to add those extentions to the filter so those files are displayed. The setting is in:
Utilities/Setup->Setup->Media Settings->Videos Settings->File Types.
Since iPodder downloads every media file listed in a feed, you'd need to use a service like
http://feedshake.com to create a feed for you based on another feed that is filtered in some way. This would allow you to download say, only "Dr. Who" from a feed that lists dozens of different shows that you don't care about.
And thats about all I can think of right now. Since I just set this up this morning, I haven't had enough time to kick the tires in on everything I've mentioned, but so far, things seem like they should work.
-Aubrey