mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
Some stream creation issues fixes
This commit is contained in:
@@ -19,6 +19,7 @@ export interface StreamOptions {
|
||||
language?: string;
|
||||
htmldata?: boolean;
|
||||
precache?: number;
|
||||
optimization?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,24 +87,27 @@ export async function stream_from_info(
|
||||
final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary;
|
||||
await request_stream(`https://${new URL(final[0].url).host}/generate_204`);
|
||||
if (type === StreamType.WebmOpus) {
|
||||
options.seek ??= 0
|
||||
if (options.seek >= info.video_details.durationInSec || options.seek < 0)
|
||||
throw new Error(`Seeking beyond limit. [ 0 - ${info.video_details.durationInSec - 1}]`);
|
||||
return new SeekStream(
|
||||
final[0].url,
|
||||
info.video_details.durationInSec,
|
||||
final[0].indexRange.end,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options
|
||||
);
|
||||
} else
|
||||
return new Stream(
|
||||
final[0].url,
|
||||
type,
|
||||
info.video_details.durationInSec,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options
|
||||
);
|
||||
options.optimization ??= true
|
||||
if(options.optimization){
|
||||
options.seek ??= 0
|
||||
if (options.seek >= info.video_details.durationInSec || options.seek < 0)
|
||||
throw new Error(`Seeking beyond limit. [ 0 - ${info.video_details.durationInSec - 1}]`);
|
||||
return new SeekStream(
|
||||
final[0].url,
|
||||
info.video_details.durationInSec,
|
||||
final[0].indexRange.end,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
return new Stream(
|
||||
final[0].url,
|
||||
type,
|
||||
info.video_details.durationInSec,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user