DEV Community

Cover image for How to download You Tube video using Python
Dheeraj-programmer
Dheeraj-programmer

Posted on • Updated on

How to download You Tube video using Python

Intro

In this post you know about how to download youtube vidoes very easily in only in only four lines of code!!

Save your time watch video!

Watch now

Requirments

pip install pytube

Pytube: Pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos. If You want to know more about pytube take a look of documentaion

Let's code

First import youtube from pytube

from pytube import YouTube
Enter fullscreen mode Exit fullscreen mode

Get more tkinter projects ideas here

Make a variable and paste the web url link of any video don't use the link which you get click on share button.

youtube = YouTube('https://www.youtube.com/watch?v=2Wb2313oHxc')
video = youtube.streams.first()
Enter fullscreen mode Exit fullscreen mode

The streams function is fetch video description, title, thumbnail and all these things but only for download video use first() with streams

Then finally use the download function to download the video and give the directory path where you want to download video

video.download('C:/Users/96650/Desktop/')
Enter fullscreen mode Exit fullscreen mode

The all code look like this!

from pytube import YouTube
youtube = YouTube('https://www.youtube.com/watch?v=2Wb2313oHxc')
video = youtube.streams.first()
video.download('C:/Users/96650/Desktop/')
Enter fullscreen mode Exit fullscreen mode

If you still reading here please like my content

For more projects subscribe to channel and

Get more Python projects here

*AFFILIATE DISCLOSER: * This post includes affiliate links.I may receive compensation if you purchase products or services from the different links provided in this article.

Latest comments (0)