LiveStream Error fixes

This commit is contained in:
killer069 2021-09-28 20:56:10 +05:30
parent 80d1ae2750
commit 9ab641d1f0
2 changed files with 11 additions and 4 deletions

View File

@ -174,7 +174,7 @@ export class Stream {
}
private async retry() {
const info = await video_info(this.video_url, this.cookie);
const info = await video_info(this.video_url, { cookie : this.cookie });
this.url = info.format[info.format.length - 1].url;
}
@ -220,8 +220,15 @@ export class Stream {
this.request = stream;
stream.pipe(this.stream, { end: false });
stream.once('error', (err) => {
this.stream.emit('error', err);
stream.once('error', async(err) => {
this.cleanup()
await this.retry();
this.loop();
if (!this.timer) {
this.timer = setInterval(() => {
this.retry();
}, 7200 * 1000);
}
});
stream.on('data', (chunk: any) => {

View File

@ -41,7 +41,7 @@ function parseAudioFormats(formats: any[]) {
export type YouTubeStream = Stream | LiveStreaming;
export async function stream(url: string, options: StreamOptions = {}): Promise<YouTubeStream> {
const info = await video_info(url, options.cookie);
const info = await video_info(url, { cookie : options.cookie });
const final: any[] = [];
if (
info.LiveStreamData.isLive === true &&