Last active
December 18, 2015 06:08
-
-
Save tdavisjr/5737413 to your computer and use it in GitHub Desktop.
Python script for downloading all of the TechEd North America 2013 conference developer related session talks only. I would copy and paste the code in your editor of choice, save it and run it. I have found that when you download these gists file the spacing gets all messed up and for a language like python that would cause the program not to ex…
This file contains hidden or 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/python | |
import os, urllib, feedparser, math, sys | |
def tofile(title): | |
title = title.replace("?", "-").replace("$", "-").replace("/", "-").replace(":", "-").replace(",", "-").replace("<", "").replace(">","") | |
return title + ".mp4" | |
def getsessions(): | |
''' | |
This requires feedparser to be loaded. E.g (pip install feedparser) | |
''' | |
try: | |
url = 'http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Developer+Tools+%26+Application+Lifecycle+Management&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf' | |
rss = feedparser.parse(url) | |
return [(tofile(e.title), e.enclosures[0].href) for e in rss.entries] | |
except: | |
print("Error reading Session RSS feed") | |
return [] | |
def reportprogress(blocksRead, blockSize, totalSize): | |
downloaded = blocksRead * blockSize | |
complete = math.ceil((downloaded / (totalSize * 1.0)) * 100) | |
sys.stdout.write("{0:.0f}%".format(complete)) | |
sys.stdout.write("\r") | |
sys.stdout.write("") | |
sys.stdout.flush() | |
def download(sessions): | |
sessions.sort() | |
for s in sessions: | |
fname = s[0] | |
url = s[1] | |
if not os.path.exists(fname): | |
try: | |
print(fname) | |
urllib.urlretrieve(url, fname, reportprogress) | |
except: | |
print("Unable to download " + url) | |
if __name__ == '__main__': | |
download(getsessions()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment