Add user-agent and extractor-args to bypass YouTube bot detection

This commit is contained in:
Peter Meier
2025-12-22 13:07:56 +01:00
parent a8f822807d
commit 923c0776e3
2 changed files with 20 additions and 1 deletions

View File

@@ -13,7 +13,11 @@ services:
- LOCALE=${LOCALE:-de} - LOCALE=${LOCALE:-de}
- LOGIN=${LOGIN:-true} - LOGIN=${LOGIN:-true}
- STREAM_ONLY=${STREAM_ONLY:-false} - STREAM_ONLY=${STREAM_ONLY:-false}
- YT_DLP_COOKIES=${YT_DLP_COOKIES:-}
- YT_DLP_COOKIES_FROM_BROWSER=${YT_DLP_COOKIES_FROM_BROWSER:-}
- YT_DLP_JS_RUNTIME=${YT_DLP_JS_RUNTIME:-deno}
volumes: volumes:
- ./downloaded:/downloaded - ./downloaded:/downloaded
- ./cookies:/cookies:ro
restart: unless-stopped restart: unless-stopped

View File

@@ -66,7 +66,12 @@ export const POST: APIRoute = async ({ request }) => {
// Zuerst Video-Informationen abrufen, um den Dateinamen zu erhalten // Zuerst Video-Informationen abrufen, um den Dateinamen zu erhalten
// getVideoInfo verwendet intern yt-dlp mit --dump-json // getVideoInfo verwendet intern yt-dlp mit --dump-json
// Deno wird beim eigentlichen Download verwendet // Deno wird beim eigentlichen Download verwendet
const videoInfoOptions: string[] = []; const videoInfoOptions: string[] = [
"--user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"--extractor-args",
"youtube:player_client=android,web",
];
if (cookiesFile) { if (cookiesFile) {
videoInfoOptions.push("--cookies", cookiesFile); videoInfoOptions.push("--cookies", cookiesFile);
} else if (cookiesFromBrowser) { } else if (cookiesFromBrowser) {
@@ -111,6 +116,11 @@ export const POST: APIRoute = async ({ request }) => {
"--no-playlist", "--no-playlist",
"--js-runtimes", "--js-runtimes",
jsRuntime, jsRuntime,
// Zusätzliche Optionen zur Umgehung der Bot-Erkennung
"--user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"--extractor-args",
"youtube:player_client=android,web",
]; ];
// Cookie-Unterstützung hinzufügen // Cookie-Unterstützung hinzufügen
@@ -216,6 +226,11 @@ export const POST: APIRoute = async ({ request }) => {
"--no-playlist", "--no-playlist",
"--js-runtimes", "--js-runtimes",
jsRuntime, jsRuntime,
// Zusätzliche Optionen zur Umgehung der Bot-Erkennung
"--user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"--extractor-args",
"youtube:player_client=android,web",
]; ];
// Cookie-Unterstützung hinzufügen // Cookie-Unterstützung hinzufügen