DEV Community

loading...
Cover image for Download YouTube videos using Python

Download YouTube videos using Python

manitej profile image Manitej ⚡ Originally published at manitej.hashnode.dev ・1 min read

Hey guys, in this short post lets see how we can download youtube videos using Python.

To make this possible, we use a package called pytube

What is pytube?

Their official docs says,

pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.

Installing pytube

Run the below command to install the pytube package.

pip install pytube
Enter fullscreen mode Exit fullscreen mode

Now, pytube is successfully installed on your system.

To download a video, simply copy the URL of that video and run the below code

from pytube import YouTube
url = "http://youtube.com/watch?v=9bZkp7q19f0"
YouTube(url).streams.first().download()
Enter fullscreen mode Exit fullscreen mode

Thats it folks :)

To learn more about pytube visit their docs

Discussion

pic
Editor guide
Collapse
hectorpascual profile image
Héctor Pascual

wow.. how easy!

Collapse
manitej profile image