Skip to content

Instantly share code, notes, and snippets.

@benroeder
Last active December 15, 2015 19:10
Show Gist options
  • Select an option

  • Save benroeder/5309609 to your computer and use it in GitHub Desktop.

Select an option

Save benroeder/5309609 to your computer and use it in GitHub Desktop.
pycon 2013 download
from urllib2 import urlopen
from subprocess import Popen, PIPE
from BeautifulSoup import *
page = urlopen('http://pyvideo.org/category/33/pycon-us-2013')
soup = BeautifulSoup(page)
video_url_list = []
count = 0
tags = soup.findAll('div', {'class': 'row section'})
for t in tags:
url_page = 'http://pyvideo.org' + t.find('a')['href']
page2 = urlopen(url_page)
soup_inner = BeautifulSoup(page2)
for a in soup_inner.findAll('a'):
if 'www.youtube.com/watch' in a.get('href', ''):
video_url_list.append(a['href'])
break
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)
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=yo4Uqq7NXQc
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=36UDNn_kS7Q
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=AqnxyRuenAg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=QUFPPJMjn6k
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=2wr8veJzZiU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=n6dUWXRdt48
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Wpv-Qb-dB6g
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=MbflVr-MBm0
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=eN1eZtjLEnU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=8SkdfdXWYaI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=t5X3ljCOFSY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=CKu6d_v4Pqo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=AQB9eECueSI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=nJff23UdNAI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=B1d9dpqBDVA
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=dQHPV6sVlls
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=gTIhUoa4G14
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=3rmCGsCYJF8
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=ICgMg70aV7U
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=mv0kfiepn3s
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=bblvGKzZfFI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=VVvqLrSMtxI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=wcqlGPWFHpk
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=7K72DPDOhWo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=ukm64IUANwE
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=o0jY0_OEyRc
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=NfngrdLv9ZQ
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=ZChp6OX59Tk
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=vvCwqHgZJc8
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=g7ka98Pq5vs
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=99l6NCL24Ek
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=k6Erh7oHvns
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=DhOv3HegnIw
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=STikIKmsOy8
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=ePFWp3oSfyU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=cJMGvAYYUyY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=k20hBed8I9M
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=poBc5__tKgU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=QpkHt1hDYTo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=0-e2-gGr2aU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=HTLu2DFOdTg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=WQQr0UM17gI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=pYZNLOKEE5I
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=SotJHYkwmVo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=5hBMlTFfOJg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=o7GR7cG7xJ0
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=voq4Mm58NY0
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=j91xUVgbQ9M
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=vW6EXOcYjIU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=A7Uw0bW1IUY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=2QELWoGNFdk
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=XkwfV8qjuK4
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=pkb5pr2Q0X0
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=u950XEl7c20
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Tedt47e9qsQ
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=jKBwGlYb13w
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=8vwtgMkqE9o
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=GBKqRhn0ekM
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=6vljQRDzIa8
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=eJcFsaVu8HI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=D9XJ9K3jfKk
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=lWKEphKIG8U
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=5GG4jBxj4Ys
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=AnwkXglmLGQ
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=1vui-LupKJI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Ta1bAMOMFOI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=hcPWAyxjd6E
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=I_d_qV3leZw
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=BBfW3m3TK0w
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=PAHBZImmXsI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=yPWj6k5MRak
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=9xciauwbsuo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=EnSu9hHGq5o
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=TH-ZCuOdrQE
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=5A5Iw9z6z2s
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=m6Ycxl918Zs
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=E708csv4XgY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=06h21nBqwec
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=WQJ67Xvw1Zo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Q9wf63flICs
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=f_6vDi7ywuA
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=QJwVYlDzAXs
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=BWyDA5y6TIg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=-JzH8TcwqxI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=UZSm7Q2bZoc
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=LCslqgM48D4
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=3MNVP9-hglc
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Nfqh6lr3frQ
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=YklKUuDpX5c
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=uAtaKr5HOdA
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=fxgEXenXNmI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=OSGv2VnC0go
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=jzzNXRGIKN4
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=oJQdX_w1vXY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=VpTPAJ0rvq8
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=C_J4_n5eC8c
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=gRvZbYtwTeo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=KEakc8r4r7M
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=iFkRt3BCctg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=4ONBVNm3isI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=vL0UtbJOKR0
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=0FZjkpoeJWM
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=mTmJfWdZzbo
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=woKYyhLCcnU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=sPiWg5jSoZI
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=9mgg45Wr8jY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=YAFyzUsZGvc
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=IjRy7dAWFdk
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Gp60Qp3GUBU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=pFMc2qFApEg
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=fH_as3eZ5YU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=NfsJDPm0X54
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Z8FC8_2h5iM
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=bP8ydKBCZiY
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=RrPZza_vZ3w
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=Nc16qeGBtMU
youtube-dl -o "%(title)s.%(ext)s" --restrict-filenames -f 18 https://www.youtube.com/watch?v=muMRNYPmQxE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment