From 7967ad51f4844be190f5fcb696ee4e135e4d7116 Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Fri, 9 Jun 2023 14:27:01 +0200 Subject: [PATCH] fix: subtitle parsing --- package.json | 2 +- src/background/background.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c1867a9..7a0d95a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Miru", - "version": "4.0.5", + "version": "4.0.6", "author": "ThaUnknown_ ", "description": "Stream anime torrents, real-time with no waiting for downloads.", "main": "build/main.js", diff --git a/src/background/background.js b/src/background/background.js index 0af4d01..d4f58b3 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -14,7 +14,6 @@ class TorrentClient extends WebTorrent { this.current = null this.parsed = false - this.parserInstance = null this.boundParse = this.parseSubtitles.bind(this) setInterval(() => { @@ -54,9 +53,8 @@ class TorrentClient extends WebTorrent { case 'current': { this.current?.removeListener('done', this.boundParse) this.cancelParse() - this.parserInstance?.destroy() - this.parserInstance = null this.current = null + this.metadata = null this.parsed = false if (data.data) { this.current = (await this.get(data.data.infoHash))?.files.find(file => file.path === data.data.path) @@ -66,9 +64,9 @@ class TorrentClient extends WebTorrent { this.parseFonts(this.current) this.current.on('iterator', ({ iterator }, cb) => { if (!this.parsed) { - this.stream = new SubtitleStream(this.stream, iterator) - this.handleSubtitleParser(this.stream, true) - cb(this.stream) + const stream = new SubtitleStream(this.metadata, iterator) + this.handleSubtitleParser(stream, true) + cb(stream) } }) } @@ -143,6 +141,7 @@ class TorrentClient extends WebTorrent { stream.once('subtitle', () => { stream.destroy() }) + this.metadata = stream } handleSubtitleParser (parser, skipFile) {