search validation added

This commit is contained in:
killer069
2021-10-09 16:18:05 +05:30
parent 1ba762d10c
commit 6698a87983
11 changed files with 199 additions and 187 deletions

View File

@@ -71,12 +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;
if(audioFormat.length !== 0) final.push(audioFormat[options.quality]);
else final.push(info.format[info.format.length - 1])
if (audioFormat.length !== 0) final.push(audioFormat[options.quality]);
else final.push(info.format[info.format.length - 1]);
let type: StreamType =
final[0].codec === 'opus' && final[0].container === 'webm'
? StreamType.WebmOpus
: StreamType.Arbitrary;
final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary;
return new Stream(
final[0].url,
type,
@@ -110,12 +108,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;
if(audioFormat.length !== 0) final.push(audioFormat[options.quality]);
else final.push(info.format[info.format.length - 1])
if (audioFormat.length !== 0) final.push(audioFormat[options.quality]);
else final.push(info.format[info.format.length - 1]);
let type: StreamType =
final[0].codec === 'opus' && final[0].container === 'webm'
? StreamType.WebmOpus
: StreamType.Arbitrary;
final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary;
return new Stream(
final[0].url,
type,