Skip to content

Instantly share code, notes, and snippets.

@abevieiramota
Created June 16, 2014 22:55
Show Gist options
  • Save abevieiramota/d0f8765109be4d56a4cc to your computer and use it in GitHub Desktop.
Save abevieiramota/d0f8765109be4d56a4cc to your computer and use it in GitHub Desktop.
Script utilizando pytube para realizar o download dos vídeos contidos em uma lista. ex utilização python download_list.py https://www.youtube.com/playlist?list=PLA89DCFA6ADACE599 mp4 360p
import sys
import urllib2
import re
from pytube import YouTube
video_RE = re.compile(r'(?<=data-video-id=").*?(?=")')
BASE = "https://www.youtube.com/watch?v=%s"
yt = YouTube()
if __name__ == "__main__":
url = sys.argv[1]
fmt = sys.argv[2]
qlty = sys.argv[3]
page = urllib2.urlopen(url).read()
for video_id in video_RE.findall(page):
url = BASE % video_id
yt.url = url
video = yt.get(fmt, qlty)
video.download()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment