Last active
August 29, 2015 14:02
-
-
Save liyong03/d973b18abf9879b7237e to your computer and use it in GitHub Desktop.
Revisions
-
liyong03 revised this gist
Jun 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,7 @@ for obj in videoList: url = obj["urls"]["HD"] print "Downloading %s: %s" %(obj["ID"], obj["name"]) output = ""+obj["ID"]+": "+obj["name"]+".mov" subprocess.call(['wget', '-c', '-P', '~/wwdc2014/', url, "-O", output]) obj["isdone"] = 1 #save new data to disk f = open("/tmp/wwdc_download", "w") -
liyong03 created this gist
Jun 10, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #!/usr/bin/python import urllib2 from xml.dom import minidom from bs4 import BeautifulSoup import json import os import subprocess #read download session videoList = [] if os.path.exists("/tmp/wwdc_download"): print "Find list!" f = open("/tmp/wwdc_download", "rw") videoList = json.load(f) f.close() else: page = urllib2.urlopen("https://developer.apple.com/videos/wwdc/2014/") print "Downloading list..." print "Get the page!" soup = BeautifulSoup(page) videos = soup.body.find_all("li", attrs={"class": "session"}) for video in videos: sessionID = video.attrs['id'] name = video.find("li", attrs={"class" : "title"}).string pDownload = video.find("p", attrs={"class" : "download"}) links = pDownload.find_all("a") urls = {} for link in links: urls[link.string] = link.attrs["href"] print "%s: %s" %(sessionID, name) #print urls["HD"] obj = {} obj["ID"] = sessionID obj["name"] = name obj["urls"] = urls obj["isdone"] = 0 videoList.append(obj) f = open("/tmp/wwdc_download", "w") json.dump(videoList, f) f.close() for obj in videoList: if obj["isdone"] == 0: url = obj["urls"]["HD"] print "Downloading %s: %s" %(obj["ID"], obj["name"]) output = ""+obj["ID"]+": "+obj["name"]+".mov" subprocess.call(['wget', '-c', '-P', '//Users/yongli/wwdc2014/', url, "-O", output]) obj["isdone"] = 1 #save new data to disk f = open("/tmp/wwdc_download", "w") json.dump(videoList, f) f.close()