« Back to Index

Python: download YouTube Videos

View original Gist on GitHub

Tags: #python #python3 #pytube #youtube #download

Download YouTube Videos with Python.py

from pytube import YouTube
from pytube.cli import on_progress

videos = [
    'https://www.youtube.com/watch?v=FOO',
    'https://www.youtube.com/watch?v=BAR',
    'https://www.youtube.com/watch?v=BAZ',
]

for video in videos:
    YouTube(video, on_progress_callback=on_progress).streams.filter(
        progressive=True,
        file_extension='mp4',
    ).order_by('resolution').desc().first().download()