From e0d0332747f7808ce71e0b6851b5553d2b29a365 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:46:23 +0530 Subject: [PATCH 1/3] Stream aborted fixes --- play-dl/YouTube/classes/LiveStream.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 4ffd623..32d264f 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -115,6 +115,7 @@ export class Stream { private url : string private bytes_count : number; private per_sec_bytes : number; + private timer : NodeJS.Timeout | null; private content_length : number private request : Request | null constructor(url : string, type : StreamType, duration : number, contentLength : number){ @@ -125,6 +126,7 @@ export class Stream { this.per_sec_bytes = Math.ceil(contentLength / duration) this.content_length = contentLength this.request = null + this.timer = null this.stream.on('close', () => { this.cleanup() }) @@ -132,8 +134,10 @@ export class Stream { } private cleanup(){ + clearTimeout(this.timer as NodeJS.Timeout) this.request?.unpipe(this.stream) this.request?.destroy() + this.timer = null this.request = null this.url = '' this.bytes_count = 0 @@ -162,9 +166,9 @@ export class Stream { this.bytes_count += chunk.length }) - stream.on('end', () => { + setTimeout(() => { if(end < this.content_length) this.loop() else this.cleanup() - }) + }, 280 * 1000) } } From 658d5b9726683dd6ae70e20388ed3da8260e79f2 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:50:19 +0530 Subject: [PATCH 2/3] Refresh Token funtion updated --- play-dl/Spotify/index.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/play-dl/Spotify/index.ts b/play-dl/Spotify/index.ts index 955c2f1..f7bec3a 100644 --- a/play-dl/Spotify/index.ts +++ b/play-dl/Spotify/index.ts @@ -158,17 +158,10 @@ export async function RefreshToken(): Promise{ if(typeof response === 'number') return false let resp_json = JSON.parse(response.body) - spotifyData = { - client_id : spotifyData.client_id, - client_secret : spotifyData.client_secret, - redirect_url : spotifyData.redirect_url, - access_token : resp_json.access_token, - refresh_token : spotifyData.refresh_token, - expires_in : Number(resp_json.expires_in), - expiry : Date.now() + (Number(resp_json.expires_in) * 1000), - token_type : resp_json.token_type, - market : spotifyData.market - } + spotifyData.access_token = resp_json.access_token + spotifyData.expires_in = Number(resp_json.expires_in) + spotifyData.expiry = Date.now() + (Number(resp_json.expires_in) * 1000) + spotifyData.token_type = resp_json.token_type fs.writeFileSync('.data/spotify.data', JSON.stringify(spotifyData, undefined, 4)) return true } \ No newline at end of file From 2b5a310fa4f15eff8d19c6e2044fa92be38eb583 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:53:07 +0530 Subject: [PATCH 3/3] package updated --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index df43a16..8376946 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "play-dl", - "version": "0.8.9", + "version": "0.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "play-dl", - "version": "0.8.9", + "version": "0.9.0", "license": "MIT", "dependencies": { "got": "^11.8.2" diff --git a/package.json b/package.json index 5ea0059..5241d90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "play-dl", - "version": "0.8.9", + "version": "0.9.0", "description": "YouTube, SoundCloud, Spotify streaming for discord.js bots", "main": "dist/index.js", "typings": "dist/index.d.ts",