Scott H’s RSS download script


Here is a script that can grab items from a rss feed:
mkdir “~\Desktop\AzureFriday”
cd “~\Desktop\AzureFriday”
[Environment]::CurrentDirectory=(Get-Location PSProvider FileSystem).ProviderPath
$a = ([xml](new-object net.webclient).downloadstring(”))
$ | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[1]
“Downloading: “ + $file
if (!(test-path $file))
(New-Object System.Net.WebClient).DownloadFile($url, $file)
This is a great example of using powershell with the ,net framework.

Lightweight Ruby Webserver to list podcasts

Once you get your head around ruby constructs the following was easy to write:

As a benefit it actually displays properly…

require ‘socket’

def latest3podcasts(session, podcast)
session.print “

  • Dir.glob(podcast)[-3..-1].each {|x| session.print “
  • #{x}
  • ” }
    session.print “


port = 8080.to_i
server =‘serveraddress’,port)
while (session = server.accept)
puts “Request: #{session.gets}”
session.print “HTTP/1.1 200/OKrnContent-type: text/htmlrnrn”
session.print “”
latest3podcasts(session, “/storage/podcast/dotnetrocks/*.mp3”)
latest3podcasts(session, “/storage/podcast/hanselminutes/*.mp3”)
latest3podcasts(session, “/storage/podcast/polymorphicpodcast/*.mp3”)
session.print “rn”

Boo Podcast Client

# (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();
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()
xnode = x.SelectSingleNode(“//channel”)
for itemnode as XmlNode in xnode.ChildNodes:
if itemnode.Name == “item”:
url = itemnode.SelectSingleNode(“enclosure/@url”).InnerText
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)
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)
return Path.GetFileName(url)