Impersonate option is not working in yt_dlp library
01:37 12 Jan 2026

I am using nightly build 2026.01.06.233142 of yt-dlp and also installed pip install "yt-dlp[default,curl-cffi]". When I use impersonate I got error. how to fix the error.

import yt_dlp
import json
import sys

# 1. Verify curl-cffi exists (Required for --impersonate)
try:
    import curl_cffi
except ImportError:
    print("Error: 'curl-cffi' is missing. Impersonation will not work.", file=sys.stderr)
    print("Fix: Run 'pip install \"yt-dlp[default,curl-cffi]\"'", file=sys.stderr)
    sys.exit(1)

url = "https://www.youtube.com/watch?v=somerandomid"

ydl_opts = {
    'quiet': True,
    'verbose': True, 
    'format': 'best',
    'js_runtimes':{'deno': {}},
    'impersonate': "chrome-116:windows-10",
    'simulate': True, 
    'skip_download': True,
    'noplaylist': True,
}

try:
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        # Extract metadata
        meta = ydl.extract_info(url, download=False)
        
        # Safe extraction with defaults
        formats = meta.get('formats', [])
        duration = meta.get('duration')
        thumbnail = meta.get('thumbnail')
        title = meta.get('title')

        output_data = []
        for item in formats:
            if item.get('audio_ext') != 'none':
                # Add metadata to the specific format object
                item.update({'duration': duration, 'thumbnail': thumbnail, 'title': title})
                output_data.append(item)
                break
            
        print(json.dumps(output_data))

except yt_dlp.utils.DownloadError as e:
    # Specific check for impersonation target errors
    if "Impersonate target" in str(e):
        print(f"FAILED: The impersonate target '{ydl_opts['impersonate']}' is invalid or unsupported by your curl-cffi version.")
    else:
        print(f"yt-dlp download error: {e}")
except Exception as e:
    print(f"General error: {e}")

This is log generated by yt_dlp

[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8

[debug] yt-dlp version nightly@2026.01.06.233142 from yt-dlp/yt-dlp-nightly-builds [27afb31ed] (pip) API

[debug] params: {'quiet': True, 'verbose': True, 'format': 'best', 'js_runtimes': {'deno': {}}, 'impersonate': 'chrome-116:windows-10', 'simulate': True, 'skip_download': True, 'noplaylist': True, 'remote_components': set(), 'compat_opts': set(), 'http_headers': {'User-Agent':

'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}

[debug] Python 3.12.4 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 3.0.13 30 Jan 2024)

[debug] exe versions: ffmpeg 2025-11-27-git-61b034a47c-full_build-www.gyan.dev (setts), ffprobe 2025-11-27-git-61b034a47c-full_build-www.gyan.dev

[debug] Optional libraries: Cryptodome-3.23.0, brotli-1.2.0, certifi-2026.01.04, curl_cffi-0.13.0, mutagen-1.47.0, requests-2.32.5, sqlite3-3.45.3, urllib3-2.6.3, websockets-16.0, yt_dlp_ejs-0.3.2

[debug] JS runtimes: deno-2.6.2

[debug] Proxy map: {}

[debug] Request Handlers: urllib, requests, websockets, curl_cffi

[debug] Plugin directories: none

General error:

python pip yt-dlp