Created
May 14, 2013 20:51
-
-
Save mortehu/5579441 to your computer and use it in GitHub Desktop.
Retrieve missing episodes of Above & Beyond: Group Therapy Radio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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