Boo Podcast Client

# Podcatcher.boo
#
# (C) Chris Eyre 2007

# This is released under the BSD licence.

#
# This is the start of a podcast download script.
# I have been unable to find a suitable podcast client to replace iPodder under Ubuntu 7.4
# so there was a need to write one.
#
# Required features:
# Download a podcast to a defined directory.
# Easy reload.
# No excessive configuration.
#
# Todo:
# Scheduler
# UI
# bitorrent support.
# Currently it is portable between Mono and .Net

import System.IO
import System.Net
import System.Xml

# This reads a file structured:
# podcastlist
# podcast
# name
# url
# output
#
def ProcessFeeds(target as string):
x = XmlDocument();
x.Load(target)
for xnode as XmlNode in x.FirstChild.ChildNodes:
url = xnode.SelectSingleNode(“url”).InnerText
name = xnode.SelectSingleNode(“output”).InnerText
ProcessFeed( url, name)

#Decodes the RSS feed.
def ProcessFeed(uri as string, output as string):
w = WebClient()
x = XmlDocument()
x.Load(w.OpenRead(uri))
xnode = x.SelectSingleNode(“//channel”)
for itemnode as XmlNode in xnode.ChildNodes:
if itemnode.Name == “item”:
url = itemnode.SelectSingleNode(“enclosure/@url”).InnerText
print(url)
GetPodcast(url, output)

// Grabs the podcast if not already got.
// If the downloaded file is corrupt then delete it and it will be replaced on the next run.
def GetPodcast(podcast as string, output as string):
filename = output + “/” + NameFromUrl(podcast)
if not File.Exists(filename):
WebClient().DownloadFile(FixUrl(podcast), filename)

# another hack for .NetRocks
def FixUrl(url as string) as string:
if Path.GetExtension(url) == “.torrent”:
return Path.ChangeExtension(url,null)
else:
return url

def NameFromUrl(url as string) as string:
#HACK: This may work for dotnet rocks, but I am still working on a torrent client
if Path.GetExtension(url) == “.torrent”:
return Path.ChangeExtension(Path.GetFileName(url),null)
else:
return Path.GetFileName(url)

ProcessFeeds(“/home/chris/Projects/PodCatcher/list.xml”)
print(“done”)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s