Fix the problem when audioFormat's length is zero.
In befor code,
```js
if(opusFormats.length === 0){
type = StreamType.Arbitrary
final.push(audioFormat[audioFormat.length - 1])
}
else{
type = StreamType.WebmOpus
final.push(opusFormats[opusFormats.length - 1])
}
if(final.length === 0) {
type = StreamType.Arbitrary
final.push(info.format[info.format.length - 1])
}
```
length of final cannot be 0 coz it only check `opusFormats.length === 0`.
This commit is contained in:
parent
2cff112d74
commit
8378056a04
@ -59,18 +59,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
|
||||||
|
if(audioFormat.length === 0){
|
||||||
|
final.push(info.format[info.format.length - 1])
|
||||||
|
}
|
||||||
|
else{
|
||||||
final.push(audioFormat[audioFormat.length - 1])
|
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))
|
return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +99,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
|
||||||
|
if(audioFormat.length === 0){
|
||||||
|
final.push(info.format[info.format.length - 1])
|
||||||
|
}
|
||||||
|
else{
|
||||||
final.push(audioFormat[audioFormat.length - 1])
|
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))
|
return new Stream(final[0].url, type, info.video_details.durationInSec, Number(final[0].contentLength))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user