Download Video from Youtube with 2 lines of code

Posted by Afsal on 06-Jan-2023

Hello Pythonistas!

Today we will learn how to download a video from a link with 2 lines of Python code. We are using a package called pytube for this. Let's jump into the code.


pip install pytube


from pytube import YouTube

YouTube("").streams.filter(progressive=True, file_extension='mp4').first().download()


Once this is run completely the mp4 file with the name same as the youtube title will be created in the same folder as the script.

I hope you have learned from this post. Please share your valuable suggestions with