mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
Merge pull request #40 from cjh980402/main
Remove useless Promise and function code
This commit is contained in:
@@ -89,8 +89,7 @@ export class LiveStreaming{
|
|||||||
if(Number(segment.split('sq/')[1].split('/')[0]) !== this.packet_count){
|
if(Number(segment.split('sq/')[1].split('/')[0]) !== this.packet_count){
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
await (async () => {
|
await new Promise((resolve, reject) => {
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
let stream = got.stream(this.base_url + segment)
|
let stream = got.stream(this.base_url + segment)
|
||||||
this.request = stream
|
this.request = stream
|
||||||
stream.on('data', (chunk: any) => this.stream.write(chunk))
|
stream.on('data', (chunk: any) => this.stream.write(chunk))
|
||||||
@@ -102,7 +101,6 @@ export class LiveStreaming{
|
|||||||
this.stream.emit('error', err)
|
this.stream.emit('error', err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
this.start()
|
this.start()
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import got, { OptionsOfTextResponseBody } from 'got/dist/source'
|
import got, { OptionsOfTextResponseBody } from 'got/dist/source'
|
||||||
|
|
||||||
export async function url_get (url : string, options? : OptionsOfTextResponseBody) : Promise<string>{
|
export async function url_get (url : string, options? : OptionsOfTextResponseBody) : Promise<string>{
|
||||||
return new Promise(async(resolve, reject) => {
|
|
||||||
let response = await got(url, options)
|
let response = await got(url, options)
|
||||||
if(response.statusCode === 200) {
|
if(response.statusCode === 200) {
|
||||||
resolve(response.body)
|
return response.body
|
||||||
}
|
}
|
||||||
else reject(`Got ${response.statusCode} from ${url}`)
|
else throw new Error(`Got ${response.statusCode} from ${url}`)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user