Fix format handling for 'best' option to prevent format errors

This commit is contained in:
Peter Meier
2025-12-22 13:42:49 +01:00
parent 5b320310d3
commit d33f6d3d91

View File

@@ -116,7 +116,9 @@ export const POST: APIRoute = async ({ request }) => {
? "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio/best[ext=mp4]/best" ? "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio/best[ext=mp4]/best"
: format === "audio" : format === "audio"
? "bestaudio[ext=m4a]/bestaudio[ext=mp3]/bestaudio" ? "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) { if (streamOnly) {
// STREAM-MODUS: Datei temporär speichern, streamen, dann löschen // STREAM-MODUS: Datei temporär speichern, streamen, dann löschen
@@ -158,6 +160,10 @@ export const POST: APIRoute = async ({ request }) => {
} else if (format === "audio") { } else if (format === "audio") {
// Für Audio: Konvertiere zu MP3 // Für Audio: Konvertiere zu MP3
execArgs.push("--extract-audio", "--audio-format", "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 ytDlpWrap
@@ -268,6 +274,10 @@ export const POST: APIRoute = async ({ request }) => {
} else if (format === "audio") { } else if (format === "audio") {
// Für Audio: Konvertiere zu MP3 // Für Audio: Konvertiere zu MP3
execArgs.push("--extract-audio", "--audio-format", "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 ytDlpWrap