Thursday, October 8, 2009

iPhone command line podacatcher

I've been using RSSPlayer to download and listen to podcasts on my iPhone, but it's started to get buggy and misses a lot of new podcast episodes.

I started looking for a simple Linux podcatcher just to check the feeds and tell if there are any new episodes. I stumbled across BashPodder, which is an excellent command line podcatcher, but it downloaded all the episodes and I only wanted to get a list of what was available.

I started looking at the code and realized it was extracting links with xsltproc. I'd never heard of that so checked into it. Basically, it takes an xsl stylesheet and filters things though it. BashPodder uses a file named parse_enclosure.xsl which is available on their website.

I realized I could use that to write a simple shell script to use on the iPhone to notify myself of new podcasts available. Then I realized I could use it to just download the podcasts instead of simply notifying me of them. The podcasts can then be listened to with iFile (from Cydia). All you need on the phone is MobileTerminal, awk, wget (any hacker should already have those), libxslt (I couldn't find it in Cydia but found it here), this script and parse_enclosure.xsl from the BashPodder project.

# Add your podcast links below and remove the ## The format must be "fetch link nickname"# fetch is the name of the function, it will only# run the function on lines beginning with the word fetch# The nickname is whatever one-word nickname you want to# give a podcast. Don't use special characters.#################FEEDLIST####################fetch http://www.site1.com/feed.xml nickname#fetch http://www.site2.com/feed.xml nickname2# ...etc###########################################

ifls | grep newthen

# If you only want to be# notified of new podcasts# and not download them,# change this line to:# cat newcat new | grep http > get; wget -i get; rm get