Skip to content

Instantly share code, notes, and snippets.

@mortehu
Created May 14, 2013 20:51
Show Gist options
  • Save mortehu/5579441 to your computer and use it in GitHub Desktop.
Save mortehu/5579441 to your computer and use it in GitHub Desktop.
Retrieve missing episodes of Above & Beyond: Group Therapy Radio
#!/usr/bin/env python
from atomicfile import AtomicFile
import feedparser
import os
import re
import urllib2
import urlparse
feed = feedparser.parse("http://www.tatw.co.uk/podcast.xml")
for item in feed["items"]:
url = item['links'][0]['href']
parsed_url = urlparse.urlparse(url, 'http')
filename = parsed_url.path.rsplit('/', 1)[-1]
if not re.search(r'ABGT[^/]*\.mp3$', filename):
continue
if os.path.isfile(filename):
continue
with AtomicFile(filename, "w") as output:
print url
u = urllib2.urlopen(url)
output.write(u.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment