prettier code

This commit is contained in:
killer069
2021-12-14 15:01:10 +05:30
parent 2974efdebc
commit af5a418d09
5 changed files with 258 additions and 255 deletions

View File

@@ -12,8 +12,8 @@ export enum StreamType {
}
export interface StreamOptions {
seekMode? : "precise" | "granular"
seek? : number
seekMode?: 'precise' | 'granular';
seek?: number;
quality?: number;
htmldata?: boolean;
}
@@ -80,25 +80,25 @@ export async function stream_from_info(
else final.push(info.format[info.format.length - 1]);
let type: StreamType =
final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary;
if(options.seek){
if(type === StreamType.WebmOpus) {
if(options.seek >= info.video_details.durationInSec) throw new Error(`Seeking beyond limit. [0 - ${info.video_details.durationInSec - 1}]`)
if (options.seek) {
if (type === StreamType.WebmOpus) {
if (options.seek >= info.video_details.durationInSec || options.seek <= 0)
throw new Error(`Seeking beyond limit. [ 1 - ${info.video_details.durationInSec - 1}]`);
return new SeekStream(
final[0].url,
info.video_details.durationInSec,
Number(final[0].contentLength),
info.video_details.url,
options
)
}
else throw new Error("Seek is only supported in Webm Opus Files.")
}
else return new Stream(
final[0].url,
type,
info.video_details.durationInSec,
Number(final[0].contentLength),
info.video_details.url,
options
);
);
} else throw new Error('Seek is only supported in Webm Opus Files.');
} else
return new Stream(
final[0].url,
type,
info.video_details.durationInSec,
Number(final[0].contentLength),
info.video_details.url,
options
);
}