PassThrough Changed
This commit is contained in:
parent
511c919366
commit
602927a5c7
@ -1,5 +1,5 @@
|
||||
import { request, request_stream } from '../YouTube/utils/request';
|
||||
import { PassThrough } from 'stream';
|
||||
import { Readable } from 'stream';
|
||||
import { IncomingMessage } from 'http';
|
||||
import { StreamType } from '../YouTube/stream';
|
||||
import { Timer } from '../YouTube/classes/LiveStream';
|
||||
@ -202,7 +202,7 @@ export class SoundCloudPlaylist {
|
||||
* SoundCloud Stream class
|
||||
*/
|
||||
export class Stream {
|
||||
stream: PassThrough;
|
||||
stream: Readable;
|
||||
type: StreamType;
|
||||
private url: string;
|
||||
private downloaded_time: number;
|
||||
@ -212,7 +212,7 @@ export class Stream {
|
||||
private time: number[];
|
||||
private segment_urls: string[];
|
||||
constructor(url: string, type: StreamType = StreamType.Arbitrary) {
|
||||
this.stream = new PassThrough({ highWaterMark: 10 * 1000 * 1000 });
|
||||
this.stream = new Readable({ highWaterMark: 10 * 1000 * 1000, read(){} });
|
||||
this.type = type;
|
||||
this.url = url;
|
||||
this.downloaded_time = 0;
|
||||
@ -274,7 +274,9 @@ export class Stream {
|
||||
}
|
||||
|
||||
this.request = stream;
|
||||
stream.pipe(this.stream, { end: false });
|
||||
stream.on('data', (c) => {
|
||||
this.stream.push(c)
|
||||
})
|
||||
stream.on('end', () => {
|
||||
if (this.downloaded_time >= 300) return;
|
||||
else this.loop();
|
||||
@ -286,7 +288,6 @@ export class Stream {
|
||||
|
||||
private cleanup() {
|
||||
this.timer.destroy();
|
||||
this.request?.unpipe(this.stream);
|
||||
this.request?.destroy();
|
||||
this.url = '';
|
||||
this.downloaded_time = 0;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PassThrough } from 'stream';
|
||||
import { Readable } from 'stream';
|
||||
import { IncomingMessage } from 'http';
|
||||
import { parseAudioFormats, StreamOptions, StreamType } from '../stream';
|
||||
import { Proxy, request, request_stream } from '../utils/request';
|
||||
@ -11,7 +11,7 @@ export interface FormatInterface {
|
||||
}
|
||||
|
||||
export class LiveStreaming {
|
||||
stream: PassThrough;
|
||||
stream: Readable;
|
||||
type: StreamType;
|
||||
private base_url: string;
|
||||
private url: string;
|
||||
@ -23,7 +23,7 @@ export class LiveStreaming {
|
||||
private segments_urls: string[];
|
||||
private request: IncomingMessage | null;
|
||||
constructor(dash_url: string, target_interval: number, video_url: string) {
|
||||
this.stream = new PassThrough({ highWaterMark: 10 * 1000 * 1000 });
|
||||
this.stream = new Readable({ highWaterMark: 10 * 1000 * 1000, read(){} });
|
||||
this.type = StreamType.Arbitrary;
|
||||
this.url = dash_url;
|
||||
this.base_url = '';
|
||||
@ -72,7 +72,6 @@ export class LiveStreaming {
|
||||
private cleanup() {
|
||||
this.timer.destroy();
|
||||
this.dash_timer.destroy();
|
||||
this.request?.unpipe(this.stream);
|
||||
this.request?.destroy();
|
||||
this.video_url = '';
|
||||
this.request = null;
|
||||
@ -102,7 +101,9 @@ export class LiveStreaming {
|
||||
return;
|
||||
}
|
||||
this.request = stream;
|
||||
stream.pipe(this.stream, { end: false });
|
||||
stream.on('data', (c) => {
|
||||
this.stream.push(c)
|
||||
})
|
||||
stream.on('end', () => {
|
||||
this.packet_count++;
|
||||
resolve('');
|
||||
@ -123,7 +124,7 @@ export class LiveStreaming {
|
||||
* Class for YouTube Stream
|
||||
*/
|
||||
export class Stream {
|
||||
stream: PassThrough;
|
||||
stream: Readable;
|
||||
type: StreamType;
|
||||
private url: string;
|
||||
private bytes_count: number;
|
||||
@ -142,7 +143,7 @@ export class Stream {
|
||||
video_url: string,
|
||||
options: StreamOptions
|
||||
) {
|
||||
this.stream = new PassThrough({ highWaterMark: 10 * 1000 * 1000 });
|
||||
this.stream = new Readable({ highWaterMark : 10 * 1000 * 1000, read(){} });
|
||||
this.url = url;
|
||||
this.quality = options.quality as number;
|
||||
this.proxy = options.proxy || undefined;
|
||||
@ -170,7 +171,6 @@ export class Stream {
|
||||
}
|
||||
|
||||
private cleanup() {
|
||||
this.request?.unpipe(this.stream);
|
||||
this.request?.destroy();
|
||||
this.request = null;
|
||||
this.url = '';
|
||||
@ -203,7 +203,9 @@ export class Stream {
|
||||
return;
|
||||
}
|
||||
this.request = stream;
|
||||
stream.pipe(this.stream, { end: false });
|
||||
stream.on('data', (c) => {
|
||||
this.stream.push(c)
|
||||
})
|
||||
|
||||
stream.once('error', async (err) => {
|
||||
this.cleanup();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user