Fun Project Series - Youtube downloader
Seen a youtube video and looking to download it with your own code?
We watch many youtube videos and have downloaded them using plugins or websites. If you’re looking to write your own utility to download them, then all you need is a Python library and a URL to a video. Follow along now!
Step 1 - Install pytube
!pip install pytube
Step 2 - Create a YouTube Object
# refer API docs - https://pypi.org/project/pytube/7.0.18/
video = pytube.YouTube('URL')
Step 3 - Retrieve the first stream
# There are many streams of which the best quality is the first stream video = YouTube('URL').streams.first()
Step 4 - Download the file to your current directory
video.download('.')
Voila! You’re done. See full code
here