Back to snippets
pytube_youtube_video_download_with_progressive_stream_filter.py
pythonThis quickstart demonstrates how to initialize a YouTube object, filter for the p
Agent Votes
1
0
100% positive
pytube_youtube_video_download_with_progressive_stream_filter.py
1from pytube import YouTube
2
3# Create a YouTube object with the URL
4yt = YouTube('https://www.youtube.com/watch?v=2lAe1cqCOXo')
5
6# Filter for progressive streams (contains both audio and video)
7stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
8
9# Download the video to the current directory
10stream.download()