diff --git a/src/pages/api/download.ts b/src/pages/api/download.ts index 48de040..5560aee 100644 --- a/src/pages/api/download.ts +++ b/src/pages/api/download.ts @@ -116,7 +116,9 @@ export const POST: APIRoute = async ({ request }) => { ? "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio/best[ext=mp4]/best" : format === "audio" ? "bestaudio[ext=m4a]/bestaudio[ext=mp3]/bestaudio" - : undefined; // undefined = yt-dlp wählt automatisch bestes Format + : format === "best" + ? undefined // Kein Format = yt-dlp wählt automatisch bestes Format + : undefined; // Fallback: yt-dlp wählt automatisch if (streamOnly) { // STREAM-MODUS: Datei temporär speichern, streamen, dann löschen @@ -158,6 +160,10 @@ export const POST: APIRoute = async ({ request }) => { } else if (format === "audio") { // Für Audio: Konvertiere zu MP3 execArgs.push("--extract-audio", "--audio-format", "mp3"); + } else if (format === "best") { + // Für "best": Keine zusätzlichen Optionen, yt-dlp wählt automatisch + // Optional: Merge-Format setzen falls Video+Audio getrennt sind + execArgs.push("--merge-output-format", "mp4"); } ytDlpWrap @@ -268,6 +274,10 @@ export const POST: APIRoute = async ({ request }) => { } else if (format === "audio") { // Für Audio: Konvertiere zu MP3 execArgs.push("--extract-audio", "--audio-format", "mp3"); + } else if (format === "best") { + // Für "best": Keine zusätzlichen Optionen, yt-dlp wählt automatisch + // Optional: Merge-Format setzen falls Video+Audio getrennt sind + execArgs.push("--merge-output-format", "mp4"); } ytDlpWrap