Installation
Install yt-dlp via pip:Basic Usage
The main entry point for using yt-dlp as a library is theYoutubeDL class:
Extract Information Without Downloading
You can extract video metadata without downloading the actual video file:Common Options
TheYoutubeDL class accepts a dictionary of options. Here are some commonly used options:
string
Video format code (e.g., ‘best’, ‘bestvideo+bestaudio’, ‘720p’)
string | dict
Output filename template. Can be a string or dictionary with keys like ‘default’
boolean
default:"false"
Do not print messages to stdout
boolean
default:"false"
Do not print out anything for warnings
boolean | string
default:"false"
Continue on download errors. Can be ‘only_download’ to ignore only download errors
boolean | string
default:"false"
Do not resolve URLs or process playlist items. Can be ‘in_playlist’, ‘discard’, or ‘discard_in_playlist’
Simple Example
Information Dictionary
When you extract information, yt-dlp returns a dictionary containing video metadata. Common fields include:id: Video identifiertitle: Video titledescription: Video descriptionuploader: Video uploader nameduration: Video duration in secondsview_count: Number of viewslike_count: Number of likesformats: List of available formatsthumbnails: List of thumbnail dictionariessubtitles: Dictionary of available subtitles
Error Handling
Next Steps
YoutubeDL Class
Deep dive into the main YoutubeDL class and its methods
Extractors
Learn about the extractor system and how to work with different sites
Post-Processors
Process downloaded media with post-processors
Examples
Browse practical code examples for common use cases