Die Option „Identitätswechsel“ funktioniert in der yt_dlp-Bibliothek nichtPython

Python-Programme
Anonymous
 Die Option „Identitätswechsel“ funktioniert in der yt_dlp-Bibliothek nicht

Post by Anonymous »

Ich verwende den nächtlichen Build 2026.01.06.233142 von yt-dlp und habe außerdem pip install „yt-dlp[default,curl-cffi]“ installiert. Wenn ich impersonate verwende, erhalte ich eine Fehlermeldung. So beheben Sie den Fehler.

Code: Select all

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}")
Dies ist ein von yt_dlp generiertes Protokoll
[debug] Kodierungen: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp-Version [email protected] von 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, wie 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. Januar 2024)
[debug] exe-Versionen: ffmpeg 2025-11-27-git-61b034a47c-full_build-www.gyan.dev (setts), ffprobe 2025-11-27-git-61b034a47c-full_build-www.gyan.dev
[debug] Optionale Bibliotheken: Cryptodome-3.23.0, brotli-1.2.0, certifi-2026.01.04, curl_cffi-0.13.0, mutagen-1.47.0, request-2.32.5, sqlite3-3.45.3, urllib3-2.6.3, websockets-16.0, yt_dlp_ejs-0.3.2
[debug] JS-Laufzeiten: deno-2.6.2
[debug] Proxy-Zuordnung: {}
[debug] Request-Handler: urllib, request, websockets, curl_cffi
[debug] Plugin-Verzeichnisse: keine
Allgemeiner Fehler:

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post