diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 54e88d2..c6a88b6 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -89,20 +89,18 @@ export class LiveStreaming{ if(Number(segment.split('sq/')[1].split('/')[0]) !== this.packet_count){ continue } - await (async () => { - return new Promise(async (resolve, reject) => { - let stream = got.stream(this.base_url + segment) - this.request = stream - stream.on('data', (chunk: any) => this.stream.write(chunk)) - stream.on('end', () => { - this.packet_count++ - resolve('') - }) - stream.once('error', (err) => { - this.stream.emit('error', err) - }) + await new Promise(async (resolve, reject) => { + let stream = got.stream(this.base_url + segment) + this.request = stream + stream.on('data', (chunk: any) => this.stream.write(chunk)) + stream.on('end', () => { + this.packet_count++ + resolve('') }) - })() + stream.once('error', (err) => { + this.stream.emit('error', err) + }) + }) } this.timer = setTimeout(() => { this.start() diff --git a/play-dl/YouTube/utils/request.ts b/play-dl/YouTube/utils/request.ts index 999c8f7..f116121 100644 --- a/play-dl/YouTube/utils/request.ts +++ b/play-dl/YouTube/utils/request.ts @@ -1,11 +1,9 @@ import got, { OptionsOfTextResponseBody } from 'got/dist/source' export async function url_get (url : string, options? : OptionsOfTextResponseBody) : Promise{ - return new Promise(async(resolve, reject) => { - let response = await got(url, options) - if(response.statusCode === 200) { - resolve(response.body) - } - else reject(`Got ${response.statusCode} from ${url}`) - }) + let response = await got(url, options) + if(response.statusCode === 200) { + return response.body + } + else throw `Got ${response.statusCode} from ${url}` } \ No newline at end of file