Download all BackboneConf2013 videos - Highest Quality
from urllib2 import urlopen
from subprocess import Popen, PIPE
from bs4 import BeautifulSoup
import os
page = urlopen('http://backboneconf.com')
soup = BeautifulSoup(page)
video_url_list = []
count = 0
tags = soup.find_all('div', {'class': 'speaker-entity'})
for t in tags:
url_page = t.find('a')
print url_page
if 'www.youtube.com/watch' in url_page.get('href', ''):
print url_page
video_url_list.append(url_page.get('href', ''))
for url in video_url_list:
print "url->"+url
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 "code-format"+code_format
videodl = 'youtube-dl -o "%%(title)s.%%(ext)s" --restrict-filenames %s' % (url)
print "Will download video:" + videodl
os.system(videodl)