Skip to content

Instantly share code, notes, and snippets.

Last active December 15, 2015 06:09
What would you like to do?
Download all Pycon 2013 Video
from urllib2 import urlopen
from subprocess import Popen, PIPE
from bs4 import BeautifulSoup
page = urlopen('')
soup = BeautifulSoup(page)
video_url_list = []
count = 0
tags = soup.find_all('div', {'class': 'section'})
for t in tags:
url_page = '' + t.find('a')['href']
soup_inner = BeautifulSoup(urlopen(url_page))
for a in soup_inner.find_all('a'):
if '' in a.get('href', ''):
for url in video_url_list:
p1 = Popen(["youtube-dl", "-F", url], stdout=PIPE)
p2 = Popen(["grep", "-i", "mp4"], stdin=p1.stdout, stdout=PIPE)
p3 = Popen(["head", "-n", "1"], stdin=p2.stdout, stdout=PIPE)
p4 = Popen(["grep", "-o", r"^[0-9]*"], stdin=p3.stdout, stdout=PIPE)
output = p4.communicate()[0]
code_format = output.strip()
print 'youtube-dl -o "%%(title)s.%%(ext)s" --restrict-filenames -f %s %s' % (code_format, url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment