Python | Download YouTube videos using youtube_dl module
Each and every day, you must be watching some video or another on YouTube which may be related to Music, Movies, Studies, Research, Leisure etc. You might want to store some video for future use where it will be required due to lack of internet or saving data or any other reason.
What if we tell you that you can do this exact very thing using Python. Let’s see how to download Youtube videos using youtube_dl module in Python.
Install the module with this command –
pip install youtube_dl
Now, suppose you are watching this video on YouTube.

Below is the Python code –
# importing module import youtube_dl ydl_opts = {} def dwl_vid(): with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([zxt]) channel = 1while (channel == int(1)): link_of_the_video = input("Copy & paste the URL of the YouTube video you want to download:- ") zxt = link_of_the_video.strip() dwl_vid() channel = int(input("Enter 1 if you want to download more videos \nEnter 0 if you are done ")) |
Output:


And it’s done. The video you want gets downloaded in the Python folder.

Recommended Posts:
- Pytube | Python library to download youtube videos
- Python | Program to download complete Youtube playlist
- YouTube Media/Audio Download using Python | pafy
- Youtube Data API for handling videos | Set-2
- Youtube Data API for handling videos | Set-3
- Youtube Data API for handling videos | Set-1
- Youtube Data API for handling videos | Set-5
- Youtube Data API for handling videos | Set-4
- Download Instagram profile pic using Python
- How to download Google Images using Python
- Download and Install Python 3 Latest Version
- Simple Multithreaded Download Manager in Python
- How to download and install Python Latest Version on Windows
- How to download and install Python Latest Version on Android
- How to download and install Python Latest Version on Linux
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


