yt-dlp

2026.3.17 · active · verified Sun Apr 05

yt-dlp is a feature-rich command-line audio/video downloader with support for thousands of sites. It is an actively maintained fork of `youtube-dl`, with frequent releases, often multiple times a month, to adapt to changes in video platforms and add new features.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `yt-dlp` as a Python library to download a video. It configures options to download the best quality MP4 video and audio, then merges them, saving the file with the video's title. For more advanced options like specifying output directories, proxies, or authentication, the `ydl_opts` dictionary should be extended.

import yt_dlp

def download_video(url):
    ydl_opts = {
        'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
        'outtmpl': '%(title)s.%(ext)s',
        'merge_output_format': 'mp4'
    }
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(url, download=False)
        video_title = info_dict.get('title', 'Unknown Title')
        print(f"Downloading: {video_title}")
        ydl.download([url])
    print("Download complete!")

if __name__ == '__main__':
    # Replace with a real video URL for testing. Use an anonymous public video.
    # For authenticated downloads, configure 'cookiefile' in ydl_opts.
    video_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" # Example URL
    download_video(video_url)

view raw JSON →