fix(media): yt-dlp format fallback chain untuk direct-file URL
upload.asepharyana.my.id redirect ke file mp3 tunggal; generic extractor yt-dlp expose format ID '0' sehingga '-f bestaudio' gagal 'Requested format is not available'. Chain bestaudio[ext=m4a]/bestaudio/best tetap dapat m4a di YouTube dan jatuh ke 'best' untuk direct file.
This commit is contained in:
@@ -31,7 +31,7 @@ export interface ResolveOptions {
|
|||||||
timeout?: number;
|
timeout?: number;
|
||||||
/**
|
/**
|
||||||
* yt-dlp format string override (e.g. "bestaudio[ext=m4a]").
|
* yt-dlp format string override (e.g. "bestaudio[ext=m4a]").
|
||||||
* Defaults to "bestaudio".
|
* Defaults to "bestaudio[ext=m4a]/bestaudio/best".
|
||||||
*/
|
*/
|
||||||
quality?: string;
|
quality?: string;
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,11 @@ export function resolveMediaUrl(
|
|||||||
options?: ResolveOptions,
|
options?: ResolveOptions,
|
||||||
): Promise<MediaSourceResolution> {
|
): Promise<MediaSourceResolution> {
|
||||||
return new Promise<MediaSourceResolution>((resolve, reject) => {
|
return new Promise<MediaSourceResolution>((resolve, reject) => {
|
||||||
const format = options?.quality ?? "bestaudio";
|
// Fallback chain: YouTube gets progressive m4a audio; direct-file hosts
|
||||||
|
// (upload mirror / Telegram files) expose a single generic format with an
|
||||||
|
// arbitrary ID — `bestaudio` alone fails there ("Requested format is not
|
||||||
|
// available"), so fall back to `bestaudio` then plain `best`.
|
||||||
|
const format = options?.quality ?? "bestaudio[ext=m4a]/bestaudio/best";
|
||||||
const cookieArgs = buildCookieArgs();
|
const cookieArgs = buildCookieArgs();
|
||||||
const args = [
|
const args = [
|
||||||
"-f",
|
"-f",
|
||||||
|
|||||||
Reference in New Issue
Block a user