diff --git a/play-dl/YouTube/classes/SeekStream.ts b/play-dl/YouTube/classes/SeekStream.ts index 62b60ef..ecae47b 100644 --- a/play-dl/YouTube/classes/SeekStream.ts +++ b/play-dl/YouTube/classes/SeekStream.ts @@ -112,12 +112,12 @@ export class SeekStream { this.request = stream; stream.pipe(this.stream, { end: false }); - this.stream.once("headComplete", () => { - stream.unpipe(this.stream) - stream.destroy() - this.stream.state = WebmSeekerState.READING_DATA - res('') - }) + this.stream.once('headComplete', () => { + stream.unpipe(this.stream); + stream.destroy(); + this.stream.state = WebmSeekerState.READING_DATA; + res(''); + }); } else res(''); }).catch((err) => err); if (parse instanceof Error) { @@ -131,7 +131,7 @@ export class SeekStream { this.timer.reuse(); return this.seek(sec); } - const bytes = this.stream.seek(sec); + const bytes = this.stream.seek(parseFloat(sec.toFixed(2))); if (bytes instanceof Error) { this.stream.emit('error', bytes); this.bytes_count = 0; diff --git a/play-dl/YouTube/classes/WebmSeeker.ts b/play-dl/YouTube/classes/WebmSeeker.ts index 9706d96..121c975 100644 --- a/play-dl/YouTube/classes/WebmSeeker.ts +++ b/play-dl/YouTube/classes/WebmSeeker.ts @@ -79,6 +79,7 @@ export class WebmSeeker extends Duplex { let position = 0; const time = Math.floor(sec / 10) * 10; this.time_left = (sec - time) * 1000 || 0; + this.time_left = Math.round(this.time_left / 20) * 20; if (!this.header.segment.cues) return new Error('Failed to Parse Cues'); for (const data of this.header.segment.cues) { @@ -131,9 +132,9 @@ export class WebmSeeker extends Duplex { if (ebmlID.name === 'ebml') this.headfound = true; else return new Error('Failed to find EBML ID at start of stream.'); } - if(ebmlID.name === "cluster") { - this.emit("headComplete") - this.cursor = this.chunk.length + if (ebmlID.name === 'cluster') { + this.emit('headComplete'); + this.cursor = this.chunk.length; break; } const data = this.chunk.slice(