Fix the problem when audioFormat's length is zero.
This commit is contained in:
Killer069 2021-09-13 10:26:12 +05:30 committed by GitHub
commit 531dc1fa2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,18 +47,18 @@ export async function stream(url : string, cookie? : string): Promise<Stream | L
if(opusFormats.length === 0){ if(opusFormats.length === 0){
type = StreamType.Arbitrary type = StreamType.Arbitrary
final.push(audioFormat[audioFormat.length - 1]) if(audioFormat.length === 0){
final.push(info.format[info.format.length - 1])
}
else{
final.push(audioFormat[audioFormat.length - 1])
}
} }
else{ else{
type = StreamType.WebmOpus type = StreamType.WebmOpus
final.push(opusFormats[opusFormats.length - 1]) final.push(opusFormats[opusFormats.length - 1])
} }
if(final.length === 0) {
type = StreamType.Arbitrary
final.push(info.format[info.format.length - 1])
}
return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength), info.video_details.url, cookie as string) return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength), info.video_details.url, cookie as string)
} }
@ -74,18 +74,18 @@ export async function stream_from_info(info : InfoData, cookie? : string): Promi
if(opusFormats.length === 0){ if(opusFormats.length === 0){
type = StreamType.Arbitrary type = StreamType.Arbitrary
final.push(audioFormat[audioFormat.length - 1]) if(audioFormat.length === 0){
final.push(info.format[info.format.length - 1])
}
else{
final.push(audioFormat[audioFormat.length - 1])
}
} }
else{ else{
type = StreamType.WebmOpus type = StreamType.WebmOpus
final.push(opusFormats[opusFormats.length - 1]) final.push(opusFormats[opusFormats.length - 1])
} }
if(final.length === 0) {
type = StreamType.Arbitrary
final.push(info.format[info.format.length - 1])
}
return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength), info.video_details.url, cookie as string) return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength), info.video_details.url, cookie as string)
} }