I know it is difficult for everyone to have an Internet Download manager or other third-party software to download a video from YouTube. But, if you are a programmer and know Python, then by running just a few lines of code, you can easily download a video from YouTube.
Python is one of the best and the most accessible programming languages for developing one's career. Generally, Python has hundreds of libraries to make working with it more comfortable, and pytube is a dependency-free Python library which is lightweight.
Pytube library in the Python programming language makes downloading the video from You Tube very easy, and it does not depend on any other Python library, so there is no need to install any additional libraries. Pytube is available in most of the Python versions (2.7 and higher).
To install the pytube library, type the following command in the terminal of your system.
pip install pytube
After installing the pytube library successfully, we need to import the YouTube module from the pytube library. The YouTube library is going to act as an Object in our program, and it provides many properties and methods like Title, rating, length, etc. We need to remember that in the 'YouTube' keyword, we must use 'Y' and 'T' as capital letters. If we don't use this case sensitive phenomena, we will end up with a bunch of errors in the program.
Use the following command to import the "YouTube" Module from the pytube library.
from pytube import YouTube
Here, I am using the VS Code to run the Python program, and the video will directly save in the path provided.
- import pytube
- from pytube import YouTube
- video_url = 'https://www.youtube.com/watch?v=5Z0rJfT0jdQ&t=5s'
- youtube = pytube.YouTube(video_url)
- video = youtube.streams.first()
- video.download('C:/Users/vkyku/Desktop/')

In this program, we are using YouTube keyword as the Object, and an object has properties and methods in any programming language.
The properties of the YouTube object are,
- Title
- Video Id
- Description
- Length
- Thumbnail_URL
- Views
- Rating
- Age Restricted
Title
YouTube returns the Title of the youtube video.
Video ID
The property video_id returns the ID of the youtube video.
Description



Stephen JhonPosted Nov 26, 2020, 9:25 AM
Interesting Article