mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
Added Seek Support
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { LiveStream, Stream } from './classes/LiveStream';
|
||||
import { SeekStream } from './classes/SeekStream';
|
||||
import { InfoData, StreamInfoData } from './utils/constants';
|
||||
import { video_stream_info } from './utils/extractor';
|
||||
|
||||
@@ -11,6 +12,7 @@ export enum StreamType {
|
||||
}
|
||||
|
||||
export interface StreamOptions {
|
||||
seek? : number
|
||||
quality?: number;
|
||||
htmldata?: boolean;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ export function parseAudioFormats(formats: any[]) {
|
||||
/**
|
||||
* Type for YouTube Stream
|
||||
*/
|
||||
export type YouTubeStream = Stream | LiveStream;
|
||||
export type YouTubeStream = Stream | LiveStream | SeekStream;
|
||||
/**
|
||||
* Stream command for YouTube
|
||||
* @param url YouTube URL
|
||||
@@ -77,7 +79,19 @@ 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;
|
||||
return new Stream(
|
||||
if(options.seek){
|
||||
if(type === StreamType.WebmOpus) {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user