Small Patch

This commit is contained in:
killer069 2021-08-31 17:28:37 +05:30
parent f8f4d88008
commit 283eabd3c9
3 changed files with 23 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "play-dl", "name": "play-dl",
"version": "0.7.2", "version": "0.7.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "play-dl", "name": "play-dl",
"version": "0.7.2", "version": "0.7.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"got": "^11.8.2" "got": "^11.8.2"

View File

@ -1,6 +1,6 @@
{ {
"name": "play-dl", "name": "play-dl",
"version": "0.7.2", "version": "0.7.3",
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots", "description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@ -77,6 +77,9 @@ export class LiveStreaming{
this.packet_count++ this.packet_count++
resolve('') resolve('')
}) })
stream.once('error', (err) => {
this.stream.emit('error', err)
})
}) })
})() })()
} }
@ -151,6 +154,9 @@ export class LiveEnded{
this.packet_count++ this.packet_count++
resolve('') resolve('')
}) })
stream.once('error', (err) => {
this.stream.emit('error', err)
})
}) })
})() })()
} }
@ -198,6 +204,11 @@ export class Stream {
} }
let stream = got.stream(this.url) let stream = got.stream(this.url)
this.request = stream this.request = stream
stream.once('error', (err) => {
this.stream.emit('error', err)
})
stream.pipe(this.stream) stream.pipe(this.stream)
} }
@ -212,6 +223,10 @@ export class Stream {
this.per_sec_bytes = Math.ceil((stream.downloadProgress.total as number)/this.duration) this.per_sec_bytes = Math.ceil((stream.downloadProgress.total as number)/this.duration)
}) })
stream.once('error', (err) => {
this.stream.emit('error', err)
})
stream.on('data', (chunk: any) => { stream.on('data', (chunk: any) => {
this.bytes_count += chunk.length this.bytes_count += chunk.length
this.stream.write(chunk) this.stream.write(chunk)
@ -244,6 +259,11 @@ export class Stream {
this.bytes_count += chunk.length this.bytes_count += chunk.length
this.stream.write(chunk) this.stream.write(chunk)
}) })
stream.once('error', (err) => {
this.stream.emit('error', err)
})
stream.on('data', () => { stream.on('data', () => {
if(absolute_bytes > (this.per_sec_bytes * 300)){ if(absolute_bytes > (this.per_sec_bytes * 300)){
stream.destroy() stream.destroy()