The Wayback Machine - https://web.archive.org/web/20250114221432/https://www.geeksforgeeks.org/python-download-youtube-videos-using-youtube_dl-module/
Open In App

Python | Download YouTube videos using yt_dlp module

Last Updated : 09 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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

yt_dlp

module in Python. Install the module with this command –

pip install yt_dlp

Now, suppose you are watching this video on YouTube.

Sample Video

Below is the Python code –

Python
import yt_dlp

ydl_opts = {}

def dwl_vid(video_url):
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([video_url])

channel = 1
while channel == 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(zxt)
    channel = int(input("Enter 1 if you want to download more videos\nEnter 0 if you are done: "))


Output:

Entering URLScreenshot-2024-08-24-223428


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

Folder

Enhance your coding skills with DSA Python, a comprehensive course focused on Data Structures and Algorithms using Python. Over 90 days, you'll explore essential algorithms, learn how to solve complex problems, and sharpen your Python programming skills. This course is perfect for anyone looking to level up their coding abilities and get ready for top tech interviews.
Join the Three 90 Challenge and commit to completing 90% of the course in 90 days to earn a 90% refund. It’s the perfect way to stay focused, track your progress, and reap the rewards of your hard work. Take the challenge and become a DSA expert in Python today


Next Article
Article Tags :
Practice Tags :

Similar Reads

three90RightbarBannerImg