Я использую ночную сборку 2026.01.06.233142 yt-dlp, а также установил pip install "yt-dlp[default,curl-cffi]". Когда я использую олицетворение, я получаю ошибку. как исправить ошибку.
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}")
Это журнал, созданный 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:**
Подробнее здесь: https://stackoverflow.com/questions/798 ... lp-library
Опция олицетворения не работает в библиотеке yt_dlp. ⇐ Python
Программы на Python
-
Anonymous
1768236832
Anonymous
Я использую ночную сборку [b]2026.01.06.233142[/b] [b]yt-dlp[/b], а также установил pip install "yt-dlp[default,curl-cffi]". Когда я использую олицетворение, я получаю ошибку. как исправить ошибку.
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}")
Это журнал, созданный 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:**
Подробнее здесь: [url]https://stackoverflow.com/questions/79865932/impersonate-option-is-not-working-in-yt-dlp-library[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия