From 4c486c024a0417d442aa7a42ed061af150574215 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Mon, 13 Sep 2021 12:41:10 +0530 Subject: [PATCH] Stream optimizations --- play-dl/YouTube/classes/LiveStream.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 0e1f9de..f8b44dc 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -143,6 +143,8 @@ export class Stream { this.stream.on('pause', () => { this.playing_count++; if(this.data_ended){ + this.bytes_count = 0 + this.per_sec_bytes = 0 this.cleanup() this.stream.removeAllListeners('pause') } @@ -168,8 +170,6 @@ export class Stream { this.request?.destroy() this.request = null this.url = '' - this.bytes_count = 0 - this.per_sec_bytes = 0 } private async loop(){ @@ -183,7 +183,7 @@ export class Stream { "range" : `bytes=${this.bytes_count}-${end >= this.content_length ? '' : end}` } }) - if(Number(stream.statusCode) >= 400 && this.bytes_count === 0){ + if(Number(stream.statusCode) >= 400){ this.cleanup() await this.retry() this.loop()