From 568624efe077654f8a66abc6361229b4a8c2b08c Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Sat, 9 Oct 2021 12:05:30 +0530 Subject: [PATCH] Format issue fixed --- play-dl/YouTube/stream.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/play-dl/YouTube/stream.ts b/play-dl/YouTube/stream.ts index 674bc9c..dc551be 100644 --- a/play-dl/YouTube/stream.ts +++ b/play-dl/YouTube/stream.ts @@ -71,9 +71,10 @@ export async function stream(url: string, options: StreamOptions = {}): Promise< if (typeof options.quality !== 'number') options.quality = audioFormat.length - 1; else if (options.quality <= 0) options.quality = 0; else if (options.quality >= audioFormat.length) options.quality = audioFormat.length - 1; - final.push(audioFormat[options.quality]); + if(audioFormat.length !== 0) final.push(audioFormat[options.quality]); + else final.push(info.format[info.format.length - 1]) let type: StreamType = - audioFormat[options.quality].codec === 'opus' && audioFormat[options.quality].container === 'webm' + final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary; return new Stream( @@ -109,9 +110,10 @@ export async function stream_from_info(info: InfoData, options: StreamOptions = if (typeof options.quality !== 'number') options.quality = audioFormat.length - 1; else if (options.quality <= 0) options.quality = 0; else if (options.quality >= audioFormat.length) options.quality = audioFormat.length - 1; - final.push(audioFormat[options.quality]); + if(audioFormat.length !== 0) final.push(audioFormat[options.quality]); + else final.push(info.format[info.format.length - 1]) let type: StreamType = - audioFormat[options.quality].codec === 'opus' && audioFormat[options.quality].container === 'webm' + final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary; return new Stream(