PodCast
Tackled on a little python module to automate the handling of enclosure tag enabled RSS feeds (Podcasts, Broadcatches or whatever buzzword that stands for that practice). Main interest actually is to integrate a podcast feature into ApnaOpus so that the client automatically fetches new torrents that were announced in the rss from the BitTorrent tracker. Nevertheless, the module already proved to be useful in combination with wget just to fetch parsed links.
PodCast basically takes an opml file as input and polls the listed feeds according to the updateInterval attribute. It issues a conditional GET to only download the feed when modifcations happened - even though it turned out that most generated rss feeds don't supply the nescessary headers. PodCast makes extensive use of libxml2 and its python bindings.
Module usage example:
from PodCast import PodCast
# options must include the opmlfile
# and can include a list of desired mediatypes
opts = {'opmlfile':'/path/to/feeds.opml',
'filtertypes':['audio/mpeg']}
# instantiating and polling
pc = PodCast.PodCast()
pc.poll(opts)
# get the enclosures
# serializeEnclosures() returns a list of dicitionaries
# containing serialized enclosure tags
enclosures = pc.serializeEnclosures(withitems=False)
There is also a poll_mainloop() method which polls periodically in a loop.
Simple retrieval with the podcast utility and wget
# save enclosed urls to be found in the feeds from # feeds.opml to enclosure.txt # (only those of type audio/mpeg) :~/podcast/$ ./podcast -i feeds.opml -o enclosures.txt -f audio/mpeg # use wget to retrieve the files wget -i enclosures.txt -P downloads/ -nc
PodCast is tested with Python 2.4
You can checkout the module and the utility from:
http://svn.var.cc/svn/podcast/ (user: anonymous, no password)








