Python: The popular object-oriented high-level programming language
Tue May 12 7:44 pm EDT 2026xtmci@atomicmail.io
Downloading YouTube videos using Python
Python's yt-dlp module allows you to download YouTube videos in quick and easy steps. First of all, install the module via pip command:
py.exe -m pip install --upgrade pip
py.exe -m pip install yt-dlp
Find out the format ID of the YouTube video you want to download. Run the yt-dlp.exe script with the self-explanatory --list-formats switch and the URL of the video:
yt-dlp.exe --list-formats https://www.youtube.com/watch?v=UAh12th345A
--list-formatsLists all available formats for the video.
Write a Python script like the following one:
import yt_dlp
url = 'https://www.youtube.com/watch?v=UAh12th345A'
options = {
# The format ID you've found earlier.
# In this case, it's for a 3840x2160 resolution mp4 file.
'format': '401',
# Saves the file as a '(title).(extension)' format.
'outtmpl': '%(title)s.%(ext)s'
}
# Downloads the file using the options and URL.
yt_dlp.YoutubeDL(options).download([url])