LiveStream Error fixes
This commit is contained in:
parent
80d1ae2750
commit
9ab641d1f0
@ -174,7 +174,7 @@ export class Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async retry() {
|
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;
|
this.url = info.format[info.format.length - 1].url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +220,15 @@ export class Stream {
|
|||||||
this.request = stream;
|
this.request = stream;
|
||||||
stream.pipe(this.stream, { end: false });
|
stream.pipe(this.stream, { end: false });
|
||||||
|
|
||||||
stream.once('error', (err) => {
|
stream.once('error', async(err) => {
|
||||||
this.stream.emit('error', err);
|
this.cleanup()
|
||||||
|
await this.retry();
|
||||||
|
this.loop();
|
||||||
|
if (!this.timer) {
|
||||||
|
this.timer = setInterval(() => {
|
||||||
|
this.retry();
|
||||||
|
}, 7200 * 1000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.on('data', (chunk: any) => {
|
stream.on('data', (chunk: any) => {
|
||||||
|
|||||||
@ -41,7 +41,7 @@ function parseAudioFormats(formats: any[]) {
|
|||||||
export type YouTubeStream = Stream | LiveStreaming;
|
export type YouTubeStream = Stream | LiveStreaming;
|
||||||
|
|
||||||
export async function stream(url: string, options: StreamOptions = {}): Promise<YouTubeStream> {
|
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[] = [];
|
const final: any[] = [];
|
||||||
if (
|
if (
|
||||||
info.LiveStreamData.isLive === true &&
|
info.LiveStreamData.isLive === true &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user