From e83b9254678fc0accea5a12dfbca887eb9dc81d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8A=88=EB=A6=AC=ED=8A=AC?= <9804cjh@naver.com> Date: Mon, 6 Sep 2021 23:37:05 +0900 Subject: [PATCH 1/5] Prevent MaxListenersExceededWarning in PassThrough --- play-dl/YouTube/classes/LiveStream.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index a67e564..d7b143e 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -90,6 +90,7 @@ export class LiveStreaming{ continue } await new Promise((resolve, reject) => { + this.request?.unpipe(this.stream) let stream = got.stream(this.base_url + segment) this.request = stream stream.pipe(this.stream, { end : false }) @@ -148,6 +149,7 @@ export class Stream { return } let absolute_bytes : number = 0 + this.request?.unpipe(this.stream) let stream = got.stream(this.url, { headers : { "range" : `bytes=${this.bytes_count}-` From 93ad5a08a3f6d648e0ce34437e2f97442b17e2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8A=88=EB=A6=AC=ED=8A=AC?= <9804cjh@naver.com> Date: Tue, 7 Sep 2021 00:25:19 +0900 Subject: [PATCH 2/5] Better solution to prevent error --- play-dl/YouTube/classes/LiveStream.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index d7b143e..7023a74 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -90,7 +90,6 @@ export class LiveStreaming{ continue } await new Promise((resolve, reject) => { - this.request?.unpipe(this.stream) let stream = got.stream(this.base_url + segment) this.request = stream stream.pipe(this.stream, { end : false }) @@ -149,7 +148,6 @@ export class Stream { return } let absolute_bytes : number = 0 - this.request?.unpipe(this.stream) let stream = got.stream(this.url, { headers : { "range" : `bytes=${this.bytes_count}-` @@ -172,6 +170,7 @@ export class Stream { this.bytes_count += chunk.length if(absolute_bytes > (this.per_sec_bytes * 300) && this.per_sec_bytes !== 0){ stream.destroy() + stream.unpipe(this.stream) } }) From 5a69be22ba70f15e2b2afb078afe8957c6624f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8A=88=EB=A6=AC=ED=8A=AC?= <9804cjh@naver.com> Date: Tue, 7 Sep 2021 01:32:34 +0900 Subject: [PATCH 3/5] Revert change of Stream class --- play-dl/YouTube/classes/LiveStream.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 7023a74..a67e564 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -170,7 +170,6 @@ export class Stream { this.bytes_count += chunk.length if(absolute_bytes > (this.per_sec_bytes * 300) && this.per_sec_bytes !== 0){ stream.destroy() - stream.unpipe(this.stream) } }) From 9d2cc09e8cff45ee166ea6441f791f66456273d0 Mon Sep 17 00:00:00 2001 From: Killer069 <65385476+killer069@users.noreply.github.com> Date: Mon, 6 Sep 2021 22:06:33 +0530 Subject: [PATCH 4/5] Added right codes --- play-dl/YouTube/classes/LiveStream.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index a67e564..ed6d4d8 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -178,6 +178,7 @@ export class Stream { }) this.timer = setTimeout(() => { + this.request?.unpipe(this.stream) this.loop() }, 280 * 1000) } From 786bfa40ee72179231541164e91473f9ba6cabb6 Mon Sep 17 00:00:00 2001 From: Killer069 <65385476+killer069@users.noreply.github.com> Date: Mon, 6 Sep 2021 23:37:59 +0530 Subject: [PATCH 5/5] Added some more unpiping --- play-dl/YouTube/classes/LiveStream.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index ed6d4d8..510e227 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -65,6 +65,7 @@ export class LiveStreaming{ private cleanup(){ clearTimeout(this.timer as NodeJS.Timer) clearTimeout(this.dash_timer as NodeJS.Timer) + this.request?.unpipe(this.stream) this.request?.destroy() this.dash_timer = null this.video_url = '' @@ -134,6 +135,7 @@ export class Stream { private cleanup(){ clearTimeout(this.timer as NodeJS.Timer) + this.request?.unpipe(this.stream) this.request?.destroy() this.request = null this.timer = null