diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 0dec6ff..914bd7d 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -174,7 +174,7 @@ export class Stream { } private async retry() { - const info = await video_info(this.video_url, this.cookie); + const info = await video_info(this.video_url, { cookie : this.cookie }); this.url = info.format[info.format.length - 1].url; } @@ -220,8 +220,15 @@ export class Stream { this.request = stream; stream.pipe(this.stream, { end: false }); - stream.once('error', (err) => { - this.stream.emit('error', err); + stream.once('error', async(err) => { + this.cleanup() + await this.retry(); + this.loop(); + if (!this.timer) { + this.timer = setInterval(() => { + this.retry(); + }, 7200 * 1000); + } }); stream.on('data', (chunk: any) => { diff --git a/play-dl/YouTube/stream.ts b/play-dl/YouTube/stream.ts index 47ba5a8..96a0d7a 100644 --- a/play-dl/YouTube/stream.ts +++ b/play-dl/YouTube/stream.ts @@ -41,7 +41,7 @@ function parseAudioFormats(formats: any[]) { export type YouTubeStream = Stream | LiveStreaming; export async function stream(url: string, options: StreamOptions = {}): Promise { - const info = await video_info(url, options.cookie); + const info = await video_info(url, { cookie : options.cookie }); const final: any[] = []; if ( info.LiveStreamData.isLive === true &&