Created
June 16, 2014 22:55
-
-
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
This file contains 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 characters
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