Skip to main content
yt-dlp can be used as a Python library to integrate video downloading capabilities into your applications. This allows you to programmatically download videos, extract metadata, and process media content.

Installation

Install yt-dlp via pip:
For development or specific features, you may need additional dependencies:

Basic Usage

The main entry point for using yt-dlp as a library is the YoutubeDL class:

Extract Information Without Downloading

You can extract video metadata without downloading the actual video file:

Common Options

The YoutubeDL 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 identifier
  • title: Video title
  • description: Video description
  • uploader: Video uploader name
  • duration: Video duration in seconds
  • view_count: Number of views
  • like_count: Number of likes
  • formats: List of available formats
  • thumbnails: List of thumbnail dictionaries
  • subtitles: 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