mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-22 05:16:22 -07:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a1d1211ae
|
||
|
|
7585d430ae
|
||
|
|
122ff9a3c5
|
||
|
|
786bd5af81
|
||
|
|
42d1384c68 |
@@ -22,7 +22,7 @@
|
||||
"@types/node": "^24.10.0",
|
||||
"@types/ws": "^8.18.1",
|
||||
"electron": "42.6.0",
|
||||
"electron-builder": "26.15.3",
|
||||
"electron-builder": "26.16.1",
|
||||
"esbuild": "^0.25.12",
|
||||
"eslint": "^10.8.0",
|
||||
"prettier": "^3.8.1",
|
||||
@@ -36,9 +36,9 @@
|
||||
},
|
||||
"overrides": {
|
||||
"@xmldom/xmldom": "0.8.15",
|
||||
"app-builder-lib": "26.15.3",
|
||||
"app-builder-lib": "26.16.1",
|
||||
"brace-expansion": "5.0.9",
|
||||
"electron-builder-squirrel-windows": "26.15.3",
|
||||
"electron-builder-squirrel-windows": "26.16.1",
|
||||
"fast-uri": "3.1.6",
|
||||
"form-data": "4.0.6",
|
||||
"ip-address": "10.2.0",
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
"@neon-rs/load": ["@neon-rs/load@0.0.4", "", {}, "sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw=="],
|
||||
|
||||
"@noble/hashes": ["@noble/hashes@2.2.0", "", {}, "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg=="],
|
||||
"@noble/hashes": ["@noble/hashes@1.8.0", "", {}, "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="],
|
||||
|
||||
"@peculiar/asn1-schema": ["@peculiar/asn1-schema@2.8.0", "", { "dependencies": { "@peculiar/utils": "^2.0.2", "asn1js": "^3.0.10", "tslib": "^2.8.1" } }, "sha512-7YT0U/ze0tF2QOBbE15gKZwy5tvgGyLRiRHLzhlbOpf7BT032oBSd0haZqXn5W6l26WLlu3dyxzjM+2638/z2Q=="],
|
||||
|
||||
@@ -243,7 +243,7 @@
|
||||
|
||||
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||
|
||||
"app-builder-lib": ["app-builder-lib@26.15.3", "", { "dependencies": { "@electron/asar": "3.4.1", "@electron/fuses": "^1.8.0", "@electron/get": "^3.0.0", "@electron/notarize": "2.5.0", "@electron/osx-sign": "1.3.3", "@electron/rebuild": "^4.0.4", "@electron/universal": "2.0.3", "@malept/flatpak-bundler": "^0.4.0", "@noble/hashes": "^2.2.0", "@peculiar/webcrypto": "^1.7.1", "@types/fs-extra": "9.0.13", "ajv": "^8.18.0", "asn1js": "^3.0.10", "async-exit-hook": "^2.0.1", "builder-util": "26.15.3", "builder-util-runtime": "9.7.0", "chromium-pickle-js": "^0.2.0", "ci-info": "4.3.1", "debug": "^4.3.4", "dotenv": "^16.4.5", "dotenv-expand": "^11.0.6", "ejs": "^3.1.8", "electron-publish": "26.15.3", "fs-extra": "^10.1.0", "hosted-git-info": "^4.1.0", "isbinaryfile": "^5.0.0", "jiti": "^2.4.2", "js-yaml": "^4.1.0", "json5": "^2.2.3", "lazy-val": "^1.0.5", "minimatch": "^10.2.5", "pkijs": "^3.4.0", "plist": "3.1.0", "proper-lockfile": "^4.1.2", "resedit": "^1.7.0", "semver": "~7.7.3", "tar": "^7.5.7", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0", "unzipper": "^0.12.3", "which": "^5.0.0" }, "peerDependencies": { "dmg-builder": "26.15.3", "electron-builder-squirrel-windows": "26.15.3" } }, "sha512-2VnyWkqsP5v5XbBhL3tD5Syx8iNPBYsoU7kY4S2fz7wg8Rj/nztWKCUzGKaFRTv0Xwf3/H058CR1Kvtd/3lRow=="],
|
||||
"app-builder-lib": ["app-builder-lib@26.16.1", "", { "dependencies": { "@electron/asar": "3.4.1", "@electron/fuses": "^1.8.0", "@electron/get": "^3.0.0", "@electron/notarize": "2.5.0", "@electron/osx-sign": "1.3.3", "@electron/rebuild": "^4.0.4", "@electron/universal": "2.0.3", "@malept/flatpak-bundler": "^0.4.0", "@noble/hashes": "^1.8.0", "@peculiar/webcrypto": "^1.7.1", "@types/fs-extra": "9.0.13", "ajv": "^8.18.0", "asn1js": "^3.0.10", "async-exit-hook": "^2.0.1", "builder-util": "26.16.0", "builder-util-runtime": "9.7.0", "chromium-pickle-js": "^0.2.0", "ci-info": "4.3.1", "debug": "^4.3.4", "dotenv": "^16.4.5", "dotenv-expand": "^11.0.6", "ejs": "^3.1.8", "electron-publish": "26.16.0", "fs-extra": "^10.1.0", "hosted-git-info": "^4.1.0", "isbinaryfile": "^5.0.0", "jiti": "^2.4.2", "js-yaml": "^4.1.0", "json5": "^2.2.3", "lazy-val": "^1.0.5", "minimatch": "^10.2.5", "pkijs": "^3.4.0", "plist": "3.1.0", "proper-lockfile": "^4.1.2", "resedit": "^1.7.0", "semver": "~7.7.3", "tar": "^7.5.7", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0", "unzipper": "^0.12.3", "which": "^5.0.0" }, "peerDependencies": { "dmg-builder": "26.16.1", "electron-builder-squirrel-windows": "26.16.1" } }, "sha512-FhaO6YOup01ZfQW0Z6gt3AyukJjv1gW4uFK47jTgwcHZKqyN/fSlK2LqPf9tAeZYLP2bRJLDzeOkRImsw2X4Pg=="],
|
||||
|
||||
"argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
|
||||
"buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
|
||||
|
||||
"builder-util": ["builder-util@26.15.3", "", { "dependencies": { "@types/debug": "^4.1.6", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "cross-spawn": "^7.0.6", "debug": "^4.3.4", "fs-extra": "^10.1.0", "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.0", "js-yaml": "^4.1.0", "sanitize-filename": "^1.6.3", "source-map-support": "^0.5.19", "stat-mode": "^1.0.0", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0" } }, "sha512-q2hn7Mbo2nFNkVekPiHFx6Nfo3hURmES3tfBn+k5Pqxl2RkmP3QGqZUhH/q9Pch/4G05NRhPjDlVj1O8q4Txvw=="],
|
||||
"builder-util": ["builder-util@26.16.0", "", { "dependencies": { "@types/debug": "^4.1.6", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "cross-spawn": "^7.0.6", "debug": "^4.3.4", "fs-extra": "^10.1.0", "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.0", "js-yaml": "^4.1.0", "sanitize-filename": "^1.6.3", "source-map-support": "^0.5.19", "stat-mode": "^1.0.0", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0" } }, "sha512-RLyJhB7Si3YkzKR9ubQslWuXW3Vhs3CGe1i+SeixBZ0qTd1mk3XBmssvY22TlB6CS5blyko8Gu1JzpYk8UkYAg=="],
|
||||
|
||||
"builder-util-runtime": ["builder-util-runtime@9.7.0", "", { "dependencies": { "debug": "^4.3.4", "sax": "^1.2.4" } }, "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw=="],
|
||||
|
||||
@@ -335,7 +335,7 @@
|
||||
|
||||
"discord-api-types": ["discord-api-types@0.38.49", "", {}, "sha512-XnqcWmnFZFAE8ZM8SHAw9DIV8D3Or00rMQ8iQLotrEA2PmXhl+ykaf6L6q4l474hrSUH1JaYcv+iOMRWp2p6Tg=="],
|
||||
|
||||
"dmg-builder": ["dmg-builder@26.15.3", "", { "dependencies": { "app-builder-lib": "26.15.3", "builder-util": "26.15.3", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0" } }, "sha512-O3zJUFUYHJKgzPqioHxfxzBzlSC1eXCSr79gMSBKBP5AgjjpmrydMsMLotEg9fAJF36vdUncb+4ndRNxoPdlSQ=="],
|
||||
"dmg-builder": ["dmg-builder@26.16.1", "", { "dependencies": { "app-builder-lib": "26.16.1", "builder-util": "26.16.0", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0" } }, "sha512-pnI/3Qb24Uk+rMTgIUrsVUKosVgwmBUdF8Zeb8TexOSbpq8MWc7v6l+n+FrEqVkjNZwzBN+XpDS9ENgZ/rkWAw=="],
|
||||
|
||||
"dotenv": ["dotenv@16.6.1", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
|
||||
|
||||
@@ -349,11 +349,11 @@
|
||||
|
||||
"electron": ["electron@42.6.0", "", { "dependencies": { "@electron-internal/extract-zip": "^1.0.1", "@electron/get": "^5.0.0", "@types/node": "^24.9.0" }, "bin": { "electron": "cli.js", "install-electron": "install.js" } }, "sha512-axGNgd+yCTg+vi1VEGrQqAj9WVWkePKwbICSAvMiT2eTaxhij9a/xhBHD6rXV8wrlW9ZfJzE5+xg752ImxrmTw=="],
|
||||
|
||||
"electron-builder": ["electron-builder@26.15.3", "", { "dependencies": { "app-builder-lib": "26.15.3", "builder-util": "26.15.3", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "ci-info": "^4.2.0", "dmg-builder": "26.15.3", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "simple-update-notifier": "2.0.0", "yargs": "^17.6.2" }, "bin": { "electron-builder": "./cli.js", "install-app-deps": "./install-app-deps.js" } }, "sha512-a1KM5heqS3gQCZzizXEI8RjJy3QVogULPdeSknt76uLDpBIW/HDGsMg/XgP0riP6PI9COsRvFITKKGDqA8fJxA=="],
|
||||
"electron-builder": ["electron-builder@26.16.1", "", { "dependencies": { "app-builder-lib": "26.16.1", "builder-util": "26.16.0", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "ci-info": "^4.2.0", "dmg-builder": "26.16.1", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "simple-update-notifier": "2.0.0", "yargs": "^17.6.2" }, "bin": { "electron-builder": "./cli.js", "install-app-deps": "./install-app-deps.js" } }, "sha512-LrLK65QX5PUYYODXqp23FKrV7CILTtVY7mrJckNknO9jLNSMiqFkKbSMiDRw4CjOADMPVDdWLxY4mezOZWswxg=="],
|
||||
|
||||
"electron-builder-squirrel-windows": ["electron-builder-squirrel-windows@26.15.3", "", { "dependencies": { "app-builder-lib": "26.15.3", "builder-util": "26.15.3", "electron-winstaller": "5.4.0" } }, "sha512-Jc19XPV9y9+2bAdZPkXuVNGNIEFBq9poHC61l8Kv6FdK7DRG3+Ic0rerC0DXOaeHNz8yW0fg/JnF8GQROOF5MA=="],
|
||||
"electron-builder-squirrel-windows": ["electron-builder-squirrel-windows@26.16.1", "", { "dependencies": { "app-builder-lib": "26.16.1", "builder-util": "26.16.0", "electron-winstaller": "5.4.0" } }, "sha512-w0y44wSaT1l6R7CAGmeHn4nHPfvzDyCAU1xJyi1w9SbPYJpYn76SmHDzqHf8Y7l91cPWTdPYBpGQtB2T5mJ08A=="],
|
||||
|
||||
"electron-publish": ["electron-publish@26.15.3", "", { "dependencies": { "@types/fs-extra": "^9.0.11", "aws4": "^1.13.2", "builder-util": "26.15.3", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "form-data": "^4.0.5", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "mime": "^2.5.2" } }, "sha512-g/2bn8YTavY4cuS5F+jOS7zmZbXXBV8KZ8yHKfJjFPoKtzBqrpCdNPxBd3tqdBwP7BVd0lGzf7Bk2s0KesWZ4Q=="],
|
||||
"electron-publish": ["electron-publish@26.16.0", "", { "dependencies": { "@types/fs-extra": "^9.0.11", "aws4": "^1.13.2", "builder-util": "26.16.0", "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "form-data": "^4.0.5", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "mime": "^2.5.2" } }, "sha512-Vt3KzQIiw9BImvNOYtndg9Mjki+tl4+1sQiC/+G5j8khWaENOJFWodiB+sUl6yyHwtd37avehskdtPw7f8y/+Q=="],
|
||||
|
||||
"electron-updater": ["electron-updater@6.8.9", "", { "dependencies": { "builder-util-runtime": "9.7.0", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0", "lazy-val": "^1.0.5", "lodash.escaperegexp": "^4.1.2", "lodash.isequal": "^4.5.0", "semver": "~7.7.3", "tiny-typed-emitter": "^2.1.0" } }, "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig=="],
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
type: docs
|
||||
area: launcher
|
||||
|
||||
- Documented private-runtime launcher installation, simplified first-run setup, custom app locations, legacy launcher migration, and package-managed updates. Updated release-note download guidance for the bundled runtime and Windows launcher.
|
||||
- Documented the bundled Bun runtime's MIT and LGPL licensing, where the notices live in the app, and the corresponding-source release asset. The AUR package now lists the bundled runtime licenses and installs their notices under `/usr/share/licenses/subminer-bin`, and `subminer-assets.tar.gz` includes the same notices.
|
||||
- Documented the bundled-runtime launcher install, legacy launcher migration, package-managed updates, and the bundled Bun runtime's MIT and LGPL notices (installed under `/usr/share/licenses/subminer-bin` by the AUR package and included in `subminer-assets.tar.gz`).
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
type: changed
|
||||
area: launcher
|
||||
|
||||
- Made every installed and downloadable launcher use the Bun runtime included with SubMiner. Added a Windows `subminer.cmd` download, persistent private runtime caches for Linux and Windows, and migration for recognized legacy launchers. Deferred migrations survive overlapping update checks and remain pending when startup cannot safely refresh the launcher.
|
||||
- Simplified first-run setup to a single optional launcher control, with runtime repair guidance shown only when needed.
|
||||
- Every installed and downloadable launcher now uses the Bun runtime bundled with SubMiner instead of a system Bun. Recognized legacy launchers migrate automatically, Windows gets a `subminer.cmd` download, and first-run setup is reduced to a single optional launcher control with runtime repair guidance shown only when needed.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
type: changed
|
||||
area: sync
|
||||
|
||||
- Sync uses compressed, incremental rsync transfers on compatible macOS and Linux machines, caching the last received snapshot per peer to reduce traffic on subsequent syncs. Cache helpers work through the launcher; older apps and launchers fall back to compressed transfers without an upload cache.
|
||||
- Machines without compatible rsync, including Windows endpoints, automatically use compressed scp transfers.
|
||||
- Rsync explicitly uses SSH and aborts transfers that exceed 30 minutes before merging.
|
||||
- Sync now uses compressed, incremental rsync transfers between compatible macOS and Linux machines, caching the last received snapshot per peer to cut traffic on later syncs. Machines without compatible rsync (including Windows) fall back to compressed scp, and older peers still work without the upload cache. Transfers abort after 30 minutes.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type: fixed
|
||||
area: anki
|
||||
|
||||
- Added `ankiConnect.fields.wordAudio` to read word audio separately from the generated sentence-audio destination, fixing animated images that start moving immediately when `fields.audio` points to `SentenceAudio`.
|
||||
- Added `ankiConnect.fields.wordAudio` so word audio is read separately from the sentence-audio destination, fixing animated images that started moving immediately when `fields.audio` pointed to `SentenceAudio`.
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
type: fixed
|
||||
area: jellyfin
|
||||
|
||||
- Set the mpv title before loading Jellyfin streams and reject URL-derived titles from metadata lookups, Anki source fields, Discord presence, and stats.
|
||||
- Keep authenticated stream URLs out of stats identities even when playback metadata has not arrived.
|
||||
- Remove previously cached credential-bearing Jellyfin stream parser metadata without changing unrelated anime metadata, watch history, or library assignments.
|
||||
- Use safe media identities for persisted AniList retry keys, discard URL-derived queued searches, and skip updates and retries whose media identity is empty.
|
||||
- Jellyfin streams no longer leak URL-derived titles or credential-bearing stream URLs into metadata lookups, Anki source fields, Discord presence, stats identities, or AniList retry keys. Previously cached credential-bearing parser metadata is cleaned up without touching watch history or library assignments.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
type: fixed
|
||||
area: jellyfin
|
||||
|
||||
- Jellyfin playback, subtitle, artwork, and remote-control URLs now authenticate with the `ApiKey` query parameter instead of the legacy `X-Emby-*` headers, so the integration works on Jellyfin 12 where legacy authorization is disabled by default.
|
||||
- "Play on SubMiner" keeps working on Jellyfin 12: the cast-target websocket answers keep-alive requests and reconnects when the server stops replying instead of silently dying after about a minute.
|
||||
- The Jellyfin "now playing" bar clears when you close or finish a cast video instead of running on to the end of the episode.
|
||||
- Anki cards mined from Jellyfin playback get the episode title in the misc info field again instead of "Unknown media".
|
||||
@@ -1,5 +1,4 @@
|
||||
type: fixed
|
||||
area: stats
|
||||
|
||||
- Stats server startup reports port conflicts without crashing SubMiner, shares concurrent startup requests, and shows in-app startup errors through configured status notifications.
|
||||
- Background stop cancels pending background startup without disconnecting foreground-only dashboards. Shutdown bounds the wait for active HTTP requests and awaits tracker finalization before exit, with a deadline for forced application exit.
|
||||
- Stats server port conflicts are reported through status notifications instead of crashing SubMiner. Startup and shutdown are also more robust: concurrent startup requests are shared, background stop no longer disconnects foreground dashboards, and shutdown bounds how long it waits for active requests.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
type: docs
|
||||
area: subtitles
|
||||
|
||||
- Explain how dialogue generation retains uncertain audible sections, why songs may also be transcribed, how detected speech starts guide long-passage cuts to reduce early subtitles, and why each passage uses a fresh Whisper process.
|
||||
- Document automatic loaded subtitle references, English dialogue preference, signs/songs filtering, fallback behavior, and the limits of reference-guided timing.
|
||||
- Documented subtitle generation: model choice, VAD behavior, reference-track guided splitting, fallback behavior, and known limits.
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
type: added
|
||||
area: subtitles
|
||||
|
||||
- Generate local Japanese SRT subtitles with whisper.cpp from a standalone modal opened with Ctrl+Shift+G, the empty subtitle sidebar's generation button, or `subminer generate-subs`, with shared progress reporting, cancellation, safe output files, and automatic loading into the matching mpv video. The sidebar button hides while subtitle lines are loaded.
|
||||
- Configure an existing multilingual model in Settings or choose an official multilingual model, including quantized variants, in the modal or launcher. The modal shows download sizes, speed and accuracy guidance, and a recommended starting model before explicitly downloading a verified SubMiner-managed model. Executable paths are optional overrides; empty fields find whisper-cli, ffmpeg, and ffprobe on PATH. The modal's Local tools check and the launcher name any missing executable and its setting before downloading a model or extracting audio, and generation confirms the destination directory grants write and search permissions up front.
|
||||
- Optionally select Focus on spoken dialogue in the modal and use Download speech detection model to install the separate Silero model with progress and cancellation. The choice lasts for the session; a configured VAD model path sets the default. Retain uncertain audible sections so VAD rejection does not discard dialogue under music, accepting that songs may also be transcribed. Keep passages intact within Whisper's audio window, split longer passages near detected speech starts or quiet pauses with overlapping context to reduce early subtitle timing, and combine overlapping duplicate cues even when punctuation differs. Run each passage in a fresh Whisper process to prevent repeated-character output caused by state carried between files, at the cost of reloading the model per passage. Preserve original media timing and separate repeated dialogue.
|
||||
- Recommend large-v3-turbo in the model picker when NVIDIA hardware and CUDA device support in the selected Whisper executable are confirmed; recommend small otherwise. Preserve configured and session model selections. Use a wider generation modal to reduce text wrapping and scrolling, while keeping it within smaller player windows.
|
||||
- Automatically use an eligible embedded or external subtitle track loaded in mpv to guide long-passage cuts, preferring English dialogue and excluding tracks marked signs, songs, forced, or generated. Honor active subtitle delays, retain unreferenced audio, and fall back to audio timing when references cannot be read. Available in the overlay and launcher, with or without VAD. The launcher captures audio selection, reference tracks, and delays before model setup so playback changes during a download do not mix inputs from different times, and rejects an unverified media snapshot before using mpv's selected audio stream.
|
||||
- Generate Japanese SRT subtitles locally with whisper.cpp from a modal (Ctrl+Shift+G), the empty subtitle sidebar's generation button, or `subminer generate-subs`, with progress, cancellation, and automatic loading into mpv.
|
||||
- Pick an official multilingual model (including quantized variants) with size and accuracy guidance and download it in-app, or point Settings at an existing model. `large-v3-turbo` is recommended when CUDA support is detected, `small` otherwise. whisper-cli, ffmpeg, and ffprobe are found on PATH unless overridden, and missing tools are named before any download starts.
|
||||
- Optional "Focus on spoken dialogue" mode uses a separately downloadable Silero VAD model, keeping uncertain audible sections so dialogue under music is not dropped (songs may be transcribed too).
|
||||
- Long passages are split near detected speech starts or quiet pauses, guided by an eligible embedded or external subtitle track already loaded in mpv when one is available, to reduce early subtitle timing. Each passage runs in a fresh Whisper process to avoid repeated-character output.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
type: docs
|
||||
area: jellyfin
|
||||
|
||||
- Explain how Jellyfin media titles, unknown-title fallbacks, and stats identities keep stream credentials out of metadata.
|
||||
- Document AniList rejection of empty media identities and the conditions for clearing cached Jellyfin parser metadata.
|
||||
- Documented how Jellyfin media titles and stats identities keep stream credentials out of metadata.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type: added
|
||||
area: overlay
|
||||
|
||||
- The overlay discovers non-conflicting keyboard bindings from mpv defaults, input.conf, and loaded scripts in the background. SubMiner controls and explicitly disabled bindings take precedence. Discovered bindings stay session-only and do not appear in SubMiner's help menu.
|
||||
- The overlay picks up non-conflicting keyboard bindings from mpv defaults, `input.conf`, and loaded scripts. SubMiner controls and explicitly disabled bindings take precedence; discovered bindings are session-only and not listed in the help menu.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
type: changed
|
||||
area: release
|
||||
|
||||
- Reduced installer and unpacked app size by excluding documentation demo media, dependency source maps, TypeScript files, test and fixture directories, other development files, and unused Koffi platform binaries, and sharing the existing Japanese UI font across windows.
|
||||
- Added package content checks, published size reports with release comparisons, and packaged asset/native-module smoke checks to the shared stable and prerelease build workflow. Size growth is reported without blocking releases.
|
||||
- Reduced installer and unpacked app size by dropping demo media, source maps, TypeScript sources, test fixtures, and unused Koffi binaries from the package, and sharing one Japanese UI font across windows. Release builds now publish package size reports with comparisons against the previous release.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type: added
|
||||
area: overlay
|
||||
|
||||
- Select dialogue across subtitle sidebar rows and copy it without timestamps using Ctrl/Cmd+C or the Copy button. Selection keeps the excerpt in view during playback and does not seek or require mining a card.
|
||||
- Select dialogue across subtitle sidebar rows and copy it without timestamps using Ctrl/Cmd+C or the Copy button. Selecting does not seek or require mining a card.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
type: changed
|
||||
breaking: true
|
||||
area: stats
|
||||
|
||||
- Reject requests from untrusted browser origins and hosts before stats data, media, or Anki operations run, and require JSON for mutation bodies.
|
||||
- Load the in-app stats overlay from the local server so it uses the same origin protection as the browser dashboard.
|
||||
- The stats server now rejects requests from non-loopback hosts and browser origins and requires `application/json` for mutation bodies. The in-app stats overlay loads from the local server so it shares the same protection. Reverse-proxied or Tailscale Serve dashboards are unsupported; scripts that POST must set a JSON content type.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type: docs
|
||||
area: stats
|
||||
|
||||
- Documented provider reassignment, merge compatibility, and TMDB credential command caching and retry cooldown.
|
||||
- Documented TMDB linking, provider reassignment, merge compatibility, and credential command caching.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
type: added
|
||||
area: stats
|
||||
|
||||
- Live-action dramas and movies in the stats Library now get posters, synopses, and titles from TMDB. Release builds include a project key, so it works out of the box; `tmdb.apiKey` (or `tmdb.apiKeyCommand`) overrides it, and is required when running from source.
|
||||
- Unlinked titles that AniList cannot match are looked up on TMDB automatically when the parsed filename matches a Japanese live-action title exactly; otherwise use the new **Link to TMDB** action on a title to pick it by hand.
|
||||
- Entries linked to the same TMDB title are merged into one card even when they came from different season folders, and the Library kind selector gained a Live Action option alongside Anime and YouTube.
|
||||
- Provider reassignment preserves the previous link and artwork if the replacement download fails, and refreshes completion totals when the episode count changes. Merges and sync keep conflicting AniList and TMDB identities separate, and the merge dialog explains when a selection mixes the two instead of failing.
|
||||
- TMDB credential commands cache successful output and wait 30 seconds before retrying failed or empty output, using the bundled key in the meantime when available.
|
||||
- Live-action dramas and movies in the stats Library get posters, synopses, and titles from TMDB. Release builds include a project key; `tmdb.apiKey` (or `tmdb.apiKeyCommand`) overrides it and is required when running from source.
|
||||
- Titles AniList cannot match are looked up on TMDB automatically when the parsed filename matches a Japanese live-action title exactly; otherwise use the new **Link to TMDB** action. Entries linked to the same TMDB title merge into one card, and the Library kind selector gained a Live Action option.
|
||||
- Provider reassignment keeps the previous link and artwork if the replacement download fails. Merges and sync keep AniList and TMDB identities separate, and the merge dialog explains mixed selections instead of failing.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type: docs
|
||||
area: anki
|
||||
|
||||
- Documented the separate word-audio mapping for animated-image synchronization and that existing images need regeneration to pick up the corrected freeze.
|
||||
- Documented the separate word-audio field mapping; existing animated images need regeneration to pick up the fix.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
type: added
|
||||
area: stats
|
||||
|
||||
- Store YouTube channels as a separate media kind and migrate existing channel entries without changing viewing history or manual video assignments, including channels created after temporarily returning to an older build.
|
||||
- Add All Titles, Anime, and YouTube Library filters, identify channel pages, and keep channels out of AniList matching, season repair, and duplicate recommendations.
|
||||
- Keep same-title anime and YouTube records separate in storage and sync while repairing legacy channel classification.
|
||||
- Refuse merges and video moves that would mix an anime entry with a YouTube channel; the move picker and merge selection only combine entries of the same kind.
|
||||
- YouTube channels are now a separate Library media kind. Existing channel entries migrate automatically without changing viewing history or manual video assignments.
|
||||
- Added All Titles, Anime, and YouTube Library filters. Channels stay out of AniList matching, season repair, and duplicate recommendations, and merges or video moves cannot mix an anime entry with a YouTube channel.
|
||||
|
||||
@@ -12,7 +12,7 @@ This is the recommended way to use Jellyfin with SubMiner. A terminal-only optio
|
||||
|
||||
## Requirements
|
||||
|
||||
- A Jellyfin server plus your username and password
|
||||
- A Jellyfin server plus your username and password (Jellyfin 12, which disables legacy authorization by default, is supported)
|
||||
- SubMiner installed and running (see [Installation](/installation))
|
||||
- On Linux, the session token is stored with `gnome-libsecret` by default
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ export async function jellyfinApiRequest<T>(
|
||||
const url = `${session.serverUrl}${requestPath}`;
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
'X-Emby-Token': session.accessToken,
|
||||
Authorization: `MediaBrowser Token="${session.accessToken}"`,
|
||||
},
|
||||
});
|
||||
@@ -103,7 +102,7 @@ export async function jellyfinApiRequest<T>(
|
||||
}
|
||||
|
||||
function itemPreviewUrl(session: JellyfinSessionConfig, id: string): string {
|
||||
return `${session.serverUrl}/Items/${id}/Images/Primary?maxHeight=720&quality=85&api_key=${encodeURIComponent(session.accessToken)}`;
|
||||
return `${session.serverUrl}/Items/${id}/Images/Primary?maxHeight=720&quality=85&ApiKey=${encodeURIComponent(session.accessToken)}`;
|
||||
}
|
||||
|
||||
function jellyfinIconCacheDir(session: JellyfinSessionConfig): string {
|
||||
|
||||
+3
-3
@@ -228,7 +228,7 @@ export function pickLibrary(
|
||||
commandExists('chafa') && commandExists('curl')
|
||||
? `
|
||||
id={1}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&api_key=${escapeShellSingle(session.accessToken)}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&ApiKey=${escapeShellSingle(session.accessToken)}
|
||||
curl -fsSL "$url" 2>/dev/null | chafa --format=symbols --symbols=vhalf+wide --size=${'${FZF_PREVIEW_COLUMNS}'}x${'${FZF_PREVIEW_LINES}'} - 2>/dev/null
|
||||
`.trim()
|
||||
: 'echo "Install curl + chafa for image preview"';
|
||||
@@ -266,7 +266,7 @@ export function pickItem(
|
||||
commandExists('chafa') && commandExists('curl')
|
||||
? `
|
||||
id={1}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&api_key=${escapeShellSingle(session.accessToken)}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&ApiKey=${escapeShellSingle(session.accessToken)}
|
||||
curl -fsSL "$url" 2>/dev/null | chafa --format=symbols --symbols=vhalf+wide --size=${'${FZF_PREVIEW_COLUMNS}'}x${'${FZF_PREVIEW_LINES}'} - 2>/dev/null
|
||||
`.trim()
|
||||
: 'echo "Install curl + chafa for image preview"';
|
||||
@@ -304,7 +304,7 @@ export function pickGroup(
|
||||
commandExists('chafa') && commandExists('curl')
|
||||
? `
|
||||
id={1}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&api_key=${escapeShellSingle(session.accessToken)}
|
||||
url=${escapeShellSingle(session.serverUrl)}/Items/$id/Images/Primary?maxHeight=720\\&quality=85\\&ApiKey=${escapeShellSingle(session.accessToken)}
|
||||
curl -fsSL "$url" 2>/dev/null | chafa --format=symbols --symbols=vhalf+wide --size=${'${FZF_PREVIEW_COLUMNS}'}x${'${FZF_PREVIEW_LINES}'} - 2>/dev/null
|
||||
`.trim()
|
||||
: 'echo "Install curl + chafa for image preview"';
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
"name": "subminer",
|
||||
"productName": "SubMiner",
|
||||
"desktopName": "SubMiner.desktop",
|
||||
"version": "0.19.6",
|
||||
"version": "0.20.0-beta.1",
|
||||
"description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration",
|
||||
"packageManager": "bun@1.3.5",
|
||||
"main": "dist/main-entry.js",
|
||||
@@ -85,9 +85,9 @@
|
||||
},
|
||||
"overrides": {
|
||||
"@xmldom/xmldom": "0.8.15",
|
||||
"app-builder-lib": "26.15.3",
|
||||
"app-builder-lib": "26.16.1",
|
||||
"brace-expansion": "5.0.9",
|
||||
"electron-builder-squirrel-windows": "26.15.3",
|
||||
"electron-builder-squirrel-windows": "26.16.1",
|
||||
"fast-uri": "3.1.6",
|
||||
"form-data": "4.0.6",
|
||||
"ip-address": "10.2.0",
|
||||
@@ -129,7 +129,7 @@
|
||||
"@types/node": "^24.10.0",
|
||||
"@types/ws": "^8.18.1",
|
||||
"electron": "42.6.0",
|
||||
"electron-builder": "26.15.3",
|
||||
"electron-builder": "26.16.1",
|
||||
"esbuild": "^0.25.12",
|
||||
"eslint": "^10.8.0",
|
||||
"prettier": "^3.8.1",
|
||||
|
||||
+86
-47
@@ -1,68 +1,107 @@
|
||||
> This is a prerelease build for testing. Stable changelog and docs-site updates remain pending until the final stable release.
|
||||
|
||||
<!-- prerelease-base-version: 0.19.4 -->
|
||||
<!-- prerelease-version: 0.20.0-beta.1 -->
|
||||
|
||||
## Highlights
|
||||
### Added
|
||||
|
||||
- Library Merge & Reassignment
|
||||
- Duplicate library cards for the same show can be combined: select entries in "Select" mode and use "Merge Selected" to combine their sessions, mined cards, and watch time onto one card.
|
||||
- Episodes can be moved to a different entry with a per-episode "→" button, fixing stray files that split off their own entry; manual assignments now survive later filename parsing, Jellyfin refreshes, and season repair.
|
||||
- Exact AniList matches with compatible seasons merge automatically, while likely (fuzzy) matches surface as a dismissible "Possible duplicate" suggestion instead of merging silently.
|
||||
- **Japanese Subtitle Generation**:
|
||||
- Generate Japanese subtitles locally with whisper.cpp, right from a modal (`Ctrl+Shift+G`), the subtitle sidebar's generation button when no subtitles are loaded, or `subminer generate-subs`, with progress, cancellation, and automatic loading into mpv when it's done.
|
||||
- Pick and download an official multilingual Whisper model in-app (including smaller quantized variants), or point Settings at one you already have. SubMiner recommends `large-v3-turbo` when CUDA is available and `small` otherwise, and tells you up front if `whisper-cli`, `ffmpeg`, or `ffprobe` can't be found.
|
||||
- An optional "Focus on spoken dialogue" mode uses a Silero VAD model to keep quiet or music-covered dialogue that would otherwise get dropped.
|
||||
- Long passages split near natural speech pauses, guided by an existing subtitle track when one is loaded, giving tighter timing and fewer repeated-word glitches.
|
||||
|
||||
- Duplicate Line Cleanup
|
||||
- The Vocabulary tab's new **Duplicates** button scans a chosen time window for the repeated-line bursts described under Fixed below and collapses each burst to a single line once confirmed.
|
||||
- A matching `subminer stats cleanup --duplicate-lines` command (with `--dry-run` and `--lookback-days <n>`) is available from the terminal.
|
||||
- Only the affected subtitle lines and the vocabulary counts they inflated are touched; watch time and lines-seen totals are left as recorded.
|
||||
- **Media Timing Review Frame Picker**:
|
||||
- The screenshot used for a mined card can now be chosen independently of the audio clip, with its own live preview, time slider, and frame-by-frame stepping.
|
||||
- Works for local video and for seekable remote streams like Jellyfin.
|
||||
|
||||
- **Overlay Keybinding Pickup**: The overlay now recognizes your mpv keybindings (from mpv's defaults, `input.conf`, and loaded scripts) as long as they don't conflict with SubMiner's own controls. Picked-up bindings work for the session but won't show up in the help menu.
|
||||
|
||||
- **Subtitle Sidebar Selection & Copy**: You can now select dialogue across multiple subtitle sidebar rows and copy it, without timestamps, using Ctrl/Cmd+C or the Copy button, without seeking or mining a card.
|
||||
|
||||
- **Jimaku Live Action Search**: The Jimaku modal has separate Anime and Live Action tabs (switch with Arrow Left/Right) so you can search Jimaku's live-action subtitle catalogue directly.
|
||||
|
||||
- **Live-Action TMDB Library**:
|
||||
- Live-action dramas and movies in the stats Library now get posters, synopses, and titles from TMDB.
|
||||
- Titles AniList can't match are looked up on TMDB automatically when the parsed filename matches a title exactly; otherwise use the new **Link to TMDB** action. Entries linked to the same TMDB title merge into one card, and the Library kind selector gained a Live Action option.
|
||||
- Release builds already include a TMDB key; if you run from source, set `tmdb.apiKey` (or `tmdb.apiKeyCommand`) yourself.
|
||||
|
||||
- **YouTube Library Kind**:
|
||||
- YouTube channels are now their own Library media kind, with new All Titles, Anime, and YouTube filters. Existing channel entries migrate automatically with viewing history and manual video assignments intact.
|
||||
- Channels stay out of AniList matching, season repair, and duplicate recommendations, and can't be merged or moved into an anime entry.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Bundled Bun Runtime**: Every SubMiner launcher, installed or downloaded, now runs on the Bun runtime bundled with the app instead of a system-wide Bun install. Recognized legacy launchers migrate automatically, Windows users get a new `subminer.cmd` download, and first-run setup now shows a single optional launcher control with runtime repair guidance only when something actually needs it.
|
||||
|
||||
- **Compressed Incremental Sync**: Cross-machine sync between compatible macOS/Linux machines now transfers only what changed, compressed, using a cached snapshot from the last sync to cut traffic further. Machines without a compatible rsync (including Windows) fall back to compressed scp automatically, older peers keep working, and transfers now time out after 30 minutes instead of hanging indefinitely.
|
||||
|
||||
- **Smaller Install Size**: Installers and the unpacked app are smaller after dropping demo media, source maps, TypeScript sources, test fixtures, and unused binaries, and sharing one Japanese UI font across windows. Release builds now publish a package-size comparison against the previous release.
|
||||
|
||||
- **Stats Server Request Safety**: The stats server, including the in-app stats overlay which now loads through it, only accepts requests from the local machine and requires a JSON content type for anything that changes data. If you were exposing the dashboard through a reverse proxy or Tailscale Serve, that's no longer supported, and any script posting to the stats API needs to send `Content-Type: application/json`.
|
||||
|
||||
- **Yomitan Updated**: Bundled Yomitan is updated to upstream 26.9.8, adding historical Japanese kana transformations and Ukrainian language support, plus improvements to Anki duplicate search and audio retrieval.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Subtitle Duplication from Karaoke & Animated Signs
|
||||
- Typeset ASS karaoke and animated signs no longer flood the overlay, subtitle sidebar, immersion history, mined cards, or stats with repeated glyph fragments or per-frame duplicates; the complete authored line is recovered instead, without merging genuinely repeated dialogue or separately positioned signs.
|
||||
- Fragmented karaoke now preserves the spaces the author placed between words instead of joining them together, and lyric transitions (including seeking into the middle of a line) resolve to the clean line instead of a stray entrance or exit frame.
|
||||
- The secondary overlay shares the same deduplication logic as the primary overlay, including collapsing lines that differ only by whitespace or trailing punctuation, and sidebar navigation moves between clean lyric lines while keeping the right line selected.
|
||||
- **Jellyfin**:
|
||||
- Playback, subtitles, artwork, and remote control now authenticate with an `ApiKey` parameter instead of legacy headers, so Jellyfin 12 works correctly even with legacy authorization disabled.
|
||||
- "Play on SubMiner" no longer silently drops the connection after about a minute on Jellyfin 12.
|
||||
- The "now playing" bar clears when you close or finish a cast video instead of running to the end of the episode.
|
||||
- Anki cards mined from Jellyfin now get the real episode title in the misc info field instead of "Unknown media".
|
||||
- Jellyfin streams no longer leak URL-derived titles or credential-bearing URLs into metadata, Anki fields, Discord presence, stats, or AniList lookups; previously cached data that had credentials in it is cleaned up automatically.
|
||||
|
||||
- Anki Media Generation
|
||||
- Sentence-audio generation no longer times out on slow network-mounted video files with many subtitle and font streams, and a failed extraction now reports a clear error instead of a raw `ENOENT`.
|
||||
- Mined audio and animated AVIF clips now capture the subtitle line you actually mined, instead of whatever line happened to be on screen once slow audio extraction finished.
|
||||
- **Anki & Mining**:
|
||||
- Word audio now reads from its own configured field (`ankiConnect.fields.wordAudio`) instead of the sentence-audio field, fixing animated word images that started moving immediately instead of on demand.
|
||||
- Setting `ankiConnect.media.maxMediaDuration` to `0` for unlimited duration now also applies when mining from the stats dashboard, matching overlay mining.
|
||||
- Closing the overlay while a media timing review is still loading now properly cancels setup, restores playback if the review had paused it, and cleans up the hidden preview player.
|
||||
|
||||
- Character Dictionary Performance & Notifications
|
||||
- Character dictionary generation, merged rebuilds, and imports no longer freeze the app on large dictionaries, and cached results (including character portraits) are reused across launches instead of regenerating everything every time.
|
||||
- Portraits also now display correctly if their cache finishes loading after subtitles have already started showing.
|
||||
- Desktop progress notifications, including on Linux AppImage installs, now update in place instead of flickering closed and reopening.
|
||||
- **Settings**:
|
||||
- AnkiConnect, Kiku, and Senren settings are now validated before use, with a warning and a safe default for anything invalid instead of a bad value reaching runtime.
|
||||
- Settings marked as applying live now correctly avoid showing a restart warning, and mixed saves apply the live parts immediately while listing only the sections that actually need a restart.
|
||||
|
||||
- Overlay Reliability
|
||||
- Overlay modals (settings, stats, etc.) now open promptly on the first shortcut press, including on repeated sessions on Windows, and appear above fullscreen mpv on macOS instead of switching Spaces or opening off-screen.
|
||||
- The macOS window-tracking helper is now built for macOS 12.0+, so the overlay attaches to mpv on older systems like Ventura instead of crashing and getting stuck on "Overlay loading."
|
||||
- The overlay no longer gets stuck on "Overlay loading" indefinitely if mpv's connection stalls; it now retries and shows an actionable error after 30 seconds.
|
||||
- Fixed native Wayland drag-and-drop from file managers like Thunar, and fixed system-wide mouse lag on Windows caused by the overlay's click-through handling.
|
||||
- **Overlay**:
|
||||
- Clicking a subtitle sidebar cue no longer leaves Space bound to seeking back to it; Enter still seeks the focused cue, and Space keeps whatever playback action you've configured.
|
||||
- Hyprland recovery dialogs now stay above SubMiner windows instead of being covered by overlay placement updates.
|
||||
- Fixed a rare case on Linux where a delayed window-close callback could reopen the overlay after it was torn down.
|
||||
|
||||
- Stats Dashboard
|
||||
- Deletes, library merges, video moves, and AniList reassignments no longer freeze the stats dashboard or rebuild lifetime totals from scratch; large deletes that used to take minutes now finish in milliseconds.
|
||||
- Vocabulary totals and charts now count all tracked vocabulary instead of just the first page, and new-word history uses corrected daily rollups.
|
||||
- Calendar labels respect time zones west of UTC, and vocabulary cards refresh automatically after editing the word exclusion list (with a Retry option if a load fails).
|
||||
- **Stats**:
|
||||
- Malformed or partly invalid resource IDs are now rejected before they can affect library mutations or cover-art backfills.
|
||||
- Stats server port conflicts now surface as a status notification instead of crashing SubMiner, and startup/shutdown are more robust: concurrent startup requests share one attempt, stopping a background instance no longer disconnects an open dashboard, and shutdown no longer waits indefinitely on active requests.
|
||||
|
||||
- Linux Launcher Thumbnails
|
||||
- Fixed missing MKV thumbnails in the Linux rofi picker when the system thumbnailer only registers legacy Matroska MIME aliases.
|
||||
- **Subtitle Sidebar Gap Follow**: The subtitle sidebar now stays near actual playback position during gaps in files where a cue starts at time zero.
|
||||
|
||||
- **First Launch on macOS**: Fixed first launch exiting immediately when the SubMiner config directory didn't exist yet.
|
||||
|
||||
## What's Changed
|
||||
|
||||
- feat(stats): add library entry merge and episode move by @ksyasuda in #190
|
||||
- fix(stats): stop counting duplicate typeset subtitle lines by @ksyasuda in #191
|
||||
- fix(media): tolerate slow MKV audio extraction by @ksyasuda in #195
|
||||
- fix(stats): subtract lifetime totals incrementally on delete by @ksyasuda in #196
|
||||
- fix(anki): snapshot mining media clip timing by @ksyasuda in #197
|
||||
- fix(notifications): replace Linux progress updates in place by @ksyasuda in #198
|
||||
- fix(overlay): support native Wayland file drag-and-drop by @ksyasuda in #199
|
||||
- fix(overlay): keep macOS modal windows on fullscreen Spaces by @ksyasuda in #200
|
||||
- fix(overlay): prevent Windows mouse lag during click-through tracking by @ksyasuda in #201
|
||||
- fix(stats): report complete vocabulary totals and new-word history by @ksyasuda in #202
|
||||
- fix(mpv): recover from stalled IPC connects by @ksyasuda in #204
|
||||
- fix(dictionary): prevent freezes and restore AppImage notifications by @ksyasuda in #205
|
||||
- fix(subtitles): recover canonical lines from ASS animation by @ksyasuda in #207
|
||||
- fix(overlay): deduplicate secondary subtitle rendering by @ksyasuda in #208
|
||||
- fix(launcher): restore Matroska thumbnails in Linux rofi picker by @ksyasuda in #210
|
||||
- fix(character-dictionary): cache completed MeCab refreshes by @ksyasuda in #212
|
||||
- feat(sidebar): add dialogue selection and copying by @ksyasuda in #238
|
||||
- feat(subtitles): add local Japanese subtitle generation by @ksyasuda in #240
|
||||
- perf(stats): use compressed incremental snapshot transfers by @ksyasuda in #241
|
||||
- fix(startup): create config directory before singleton lock by @ksyasuda in #242
|
||||
- feat(launcher): bundle Bun and use it across all launchers by @ksyasuda in #243
|
||||
- build(release): reduce package size and report release sizes by @ksyasuda in #244
|
||||
- fix(overlay): keep Hyprland recovery dialogs above overlays by @ksyasuda in #245
|
||||
- feat(overlay): discover unclaimed mpv key bindings by @ksyasuda in #246
|
||||
- fix(sidebar): preserve Space playback after cue seeking by @ksyasuda in #247
|
||||
- fix(jellyfin): fix jellyfin media metadata by @ksyasuda in #250
|
||||
- feat(jimaku): add live-action subtitle search by @ksyasuda in #251
|
||||
- feat(stats): add TMDB metadata for live-action dramas in the Library by @ksyasuda in #252
|
||||
- feat(stats): separate YouTube channels in the Library by @ksyasuda in #253
|
||||
- feat(mining): add a screenshot frame picker to media review by @aalhendi in #254
|
||||
- fix(config): align live save feedback with hot reload policy by @ksyasuda in #255
|
||||
- fix(anki): separate word audio mapping for animation sync by @ksyasuda in #256
|
||||
- fix(config): validate AnkiConnect and field grouping settings by @ksyasuda in #257
|
||||
- fix(anki): honor unlimited duration in stats mining by @ksyasuda in #258
|
||||
- fix(stats): reject malformed resource IDs before mutations by @ksyasuda in #259
|
||||
- fix(stats): harden server lifecycle and verify compiled runtime by @ksyasuda in #261
|
||||
- fix(overlay): cancel pending window transitions and timing reviews by @ksyasuda in #262
|
||||
- fix(stats): restrict local requests and serve the dashboard over HTTP by @ksyasuda in #263
|
||||
- fix(jellyfin): support modern authentication by @ksyasuda in #264
|
||||
|
||||
## New Contributors
|
||||
|
||||
- @aalhendi made their first contribution in #254
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -51,10 +51,13 @@ function listFiles(root, prefix = '') {
|
||||
});
|
||||
}
|
||||
|
||||
// asar resolves lookups with the platform separator, so stat with the listed
|
||||
// native path and only normalize the reported name.
|
||||
function listAppFiles(archive) {
|
||||
return asar.listPackage(archive).flatMap((entry) => {
|
||||
const name = entry.replaceAll('\\', '/').replace(/^\//, '');
|
||||
const stat = asar.statFile(archive, name);
|
||||
const native = entry.replace(/^[\\/]/, '');
|
||||
const stat = asar.statFile(archive, native);
|
||||
const name = native.replaceAll('\\', '/');
|
||||
return 'size' in stat ? [{ path: name, bytes: stat.size }] : [];
|
||||
});
|
||||
}
|
||||
@@ -129,7 +132,7 @@ function verifyContents(archive, resources, platform, arch) {
|
||||
assert(!name.path.startsWith('minecard'), `Demo media shipped: ${name.path}`);
|
||||
}
|
||||
for (const ui of ['renderer', 'settings', 'syncui']) {
|
||||
const css = asar.extractFile(archive, `dist/${ui}/style.css`).toString();
|
||||
const css = asar.extractFile(archive, path.join('dist', ui, 'style.css')).toString();
|
||||
assert(css.includes('../fonts/MPLUS1[wght].ttf'), `Shared font missing from ${ui} CSS`);
|
||||
}
|
||||
return entries;
|
||||
|
||||
@@ -134,10 +134,12 @@ test('archive inventory handles native files without counting them twice on disk
|
||||
mkdirSync(output);
|
||||
writeFileSync(path.join(input, 'main.js'), 'hello');
|
||||
writeFileSync(path.join(input, 'native.node'), 'native');
|
||||
mkdirSync(path.join(input, 'dist', 'ai'), { recursive: true });
|
||||
writeFileSync(path.join(input, 'dist', 'ai', 'client.js'), 'nested');
|
||||
const archive = path.join(output, 'app.asar');
|
||||
await createPackageFromStreams(
|
||||
archive,
|
||||
['main.js', 'native.node'].map((name) => ({
|
||||
['main.js', 'native.node', 'dist/ai/client.js'].map((name) => ({
|
||||
path: name,
|
||||
type: 'file',
|
||||
unpacked: name.endsWith('.node'),
|
||||
@@ -148,6 +150,7 @@ test('archive inventory handles native files without counting them twice on disk
|
||||
assert.deepEqual(listAppFiles(archive), [
|
||||
{ path: 'main.js', bytes: 5 },
|
||||
{ path: 'native.node', bytes: 6 },
|
||||
{ path: 'dist/ai/client.js', bytes: 6 },
|
||||
]);
|
||||
assert.equal(
|
||||
listFiles(output).reduce((sum: number, entry: { bytes: number }) => sum + entry.bytes, 0),
|
||||
|
||||
@@ -14,7 +14,12 @@ delete env.ELECTRON_RUN_AS_NODE;
|
||||
try {
|
||||
const result = spawnSync(
|
||||
require('electron'),
|
||||
[fileURLToPath(new URL('./smoke-package.cjs', import.meta.url)), path.resolve(resources)],
|
||||
[
|
||||
fileURLToPath(new URL('./smoke-package.cjs', import.meta.url)),
|
||||
path.resolve(resources),
|
||||
// CI runners lack a setuid chrome-sandbox; this harness never loads remote content.
|
||||
...(process.platform === 'linux' ? ['--no-sandbox'] : []),
|
||||
],
|
||||
{ env, stdio: 'inherit', timeout: 75_000 },
|
||||
);
|
||||
if (result.error) throw result.error;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Run with the pinned Electron runtime against a finished app's resources folder.
|
||||
const { app, BrowserWindow, session } = require('electron');
|
||||
const fs = require('node:fs');
|
||||
const http = require('node:http');
|
||||
const path = require('node:path');
|
||||
const { createRequire } = require('node:module');
|
||||
const assert = require('node:assert/strict');
|
||||
@@ -21,6 +22,39 @@ const timeout = setTimeout(() => {
|
||||
app.exit(1);
|
||||
}, 60_000);
|
||||
|
||||
const STATIC_TYPES = {
|
||||
'.html': 'text/html',
|
||||
'.js': 'text/javascript',
|
||||
'.css': 'text/css',
|
||||
'.png': 'image/png',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.woff2': 'font/woff2',
|
||||
'.ttf': 'font/ttf',
|
||||
'.json': 'application/json',
|
||||
};
|
||||
|
||||
// The stats dashboard is served by the stats HTTP server in the app, so load it
|
||||
// over loopback HTTP from the packaged stats/dist and treat missing static
|
||||
// assets as failures. API routes are not part of this smoke and may 404.
|
||||
function serveStatsDist(root, failedRequests) {
|
||||
const server = http.createServer((req, res) => {
|
||||
const pathname = new URL(req.url, 'http://127.0.0.1').pathname;
|
||||
const relative = pathname === '/' ? 'index.html' : pathname.slice(1);
|
||||
try {
|
||||
const body = fs.readFileSync(path.join(root, relative));
|
||||
res.writeHead(200, {
|
||||
'Content-Type': STATIC_TYPES[path.extname(relative)] ?? 'application/octet-stream',
|
||||
});
|
||||
res.end(body);
|
||||
} catch {
|
||||
if (!pathname.startsWith('/api/')) failedRequests.push(`${req.url}: missing static asset`);
|
||||
res.writeHead(404).end();
|
||||
}
|
||||
});
|
||||
server.listen(0, '127.0.0.1');
|
||||
return server;
|
||||
}
|
||||
|
||||
async function smoke() {
|
||||
await app.whenReady();
|
||||
const packagedRequire = createRequire(path.join(archive, 'package.json'));
|
||||
@@ -50,10 +84,17 @@ async function smoke() {
|
||||
);
|
||||
assert(extension.id, 'Yomitan extension failed to load');
|
||||
const failedRequests = [];
|
||||
session.defaultSession.webRequest.onErrorOccurred({ urls: ['file://*/*'] }, (details) => {
|
||||
if (details.error !== 'net::ERR_ABORTED')
|
||||
failedRequests.push(`${details.url}: ${details.error}`);
|
||||
});
|
||||
session.defaultSession.webRequest.onErrorOccurred(
|
||||
{ urls: ['file://*/*', 'http://127.0.0.1/*'] },
|
||||
(details) => {
|
||||
// Chromium probes the cache before fetching @font-face fonts; an uncached
|
||||
// font reports ERR_CACHE_MISS and is then fetched normally.
|
||||
if (!['net::ERR_ABORTED', 'net::ERR_CACHE_MISS'].includes(details.error))
|
||||
failedRequests.push(`${details.url}: ${details.error}`);
|
||||
},
|
||||
);
|
||||
const statsServer = serveStatsDist(path.join(archive, 'stats', 'dist'), failedRequests);
|
||||
await once(statsServer, 'listening');
|
||||
for (const ui of ['renderer', 'settings', 'syncui', 'stats']) {
|
||||
const win = new BrowserWindow({
|
||||
show: false,
|
||||
@@ -63,10 +104,12 @@ async function smoke() {
|
||||
},
|
||||
});
|
||||
try {
|
||||
await win.loadFile(
|
||||
path.join(archive, ui === 'stats' ? 'stats/dist/index.html' : `dist/${ui}/index.html`),
|
||||
);
|
||||
if (ui !== 'stats') {
|
||||
if (ui === 'stats') {
|
||||
await win.loadURL(`http://127.0.0.1:${statsServer.address().port}/`);
|
||||
// Let in-flight font requests settle before the window goes away.
|
||||
await win.webContents.executeJavaScript('document.fonts.ready.then(() => true)');
|
||||
} else {
|
||||
await win.loadFile(path.join(archive, `dist/${ui}/index.html`));
|
||||
const loaded = await win.webContents.executeJavaScript(
|
||||
`document.fonts.load('400 16px "M PLUS 1"', '日本語').then(fonts => fonts.length > 0 && fonts.every(font => font.status === 'loaded'))`,
|
||||
);
|
||||
@@ -76,6 +119,7 @@ async function smoke() {
|
||||
win.destroy();
|
||||
}
|
||||
}
|
||||
statsServer.close();
|
||||
assert.deepEqual(failedRequests, [], 'Packaged UI resources failed to load');
|
||||
console.log(
|
||||
'Package smoke passed: SQLite, platform FFI, texthooker, Yomitan loading, UI pages, shared Japanese font.',
|
||||
|
||||
@@ -1545,3 +1545,25 @@ test('Anki metadata rejects a credential-bearing media title before metadata arr
|
||||
const result = privateApi.formatMiscInfoPattern('stream?api_key=test-secret', 426);
|
||||
assert.equal(result, '[SubMiner] Unknown media | Unknown media (00:07:06)');
|
||||
});
|
||||
|
||||
test('AnkiIntegration.formatMiscInfoPattern treats ApiKey stream paths like legacy api_key ones', () => {
|
||||
const integration = new AnkiIntegration(
|
||||
{ metadata: { pattern: '[SubMiner] %f (%t)' } } as never,
|
||||
{} as never,
|
||||
{
|
||||
currentSubText: '',
|
||||
currentVideoPath: 'stream?static=true&ApiKey=secret-token&MediaSourceId=ms-1',
|
||||
currentTimePos: 426,
|
||||
currentSubStart: 426,
|
||||
currentSubEnd: 428,
|
||||
currentMediaTitle: '[Jellyfin/direct] Bocchi the Rock! - S01E02',
|
||||
send: () => true,
|
||||
} as unknown as never,
|
||||
);
|
||||
const privateApi = integration as unknown as {
|
||||
formatMiscInfoPattern: (fallbackFilename: string, startTimeSeconds?: number) => string;
|
||||
};
|
||||
const result = privateApi.formatMiscInfoPattern('audio_123.mp3', 426);
|
||||
assert.equal(result, '[SubMiner] [Jellyfin/direct] Bocchi the Rock! - S01E02 (00:07:06)');
|
||||
assert.equal(result.includes('ApiKey='), false);
|
||||
});
|
||||
|
||||
@@ -185,7 +185,7 @@ function extractFilenameFromMediaPath(rawPath: string): string {
|
||||
function shouldPreferMediaTitleForMiscInfo(rawPath: string, filename: string): boolean {
|
||||
const loweredPath = rawPath.toLowerCase();
|
||||
const loweredFilename = filename.toLowerCase();
|
||||
if (loweredPath.includes('api_key=')) {
|
||||
if (loweredPath.includes('api_key=') || loweredPath.includes('apikey=')) {
|
||||
return true;
|
||||
}
|
||||
if (loweredPath.startsWith('http://') || loweredPath.startsWith('https://')) {
|
||||
|
||||
@@ -3174,6 +3174,7 @@ test('Jellyfin metadata cleanup requires both an API key and a stream marker', a
|
||||
{ filename: 'stream?api_key=secret', leaked: true },
|
||||
{ filename: '/STREAM?API_KEY=secret', leaked: true },
|
||||
{ filename: '/Videos/item?api_key=secret', leaked: true },
|
||||
{ filename: '/Videos/item?ApiKey=secret', leaked: true },
|
||||
{ filename: 'MediaSourceId=item api key secret', leaked: true },
|
||||
{ filename: 'An API Key Story', leaked: false },
|
||||
{ filename: 'api_key=ordinary-metadata', leaked: false },
|
||||
|
||||
@@ -376,6 +376,7 @@ function buildJellyfinStatsMediaPath(mediaPath: string, itemId: string): string
|
||||
|
||||
const JELLYFIN_MEDIA_ALIAS_QUERY_KEYS = [
|
||||
'api_key',
|
||||
'ApiKey',
|
||||
'StartTimeTicks',
|
||||
'AudioStreamIndex',
|
||||
'SubtitleStreamIndex',
|
||||
|
||||
@@ -82,7 +82,7 @@ function parseLegacyJellyfinStreamUrl(value: string | null): URL | null {
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (!url.searchParams.has('api_key')) {
|
||||
if (!url.searchParams.has('api_key') && !url.searchParams.has('ApiKey')) {
|
||||
return null;
|
||||
}
|
||||
return url;
|
||||
@@ -130,13 +130,13 @@ function repairLeakedJellyfinAnimeTitles(db: DatabaseSync, currentTimestamp: str
|
||||
SELECT v.canonical_title
|
||||
FROM imm_videos v
|
||||
WHERE v.anime_id = a.anime_id
|
||||
AND v.canonical_title NOT LIKE '%api_key=%'
|
||||
AND v.canonical_title NOT LIKE '%api_key=%' AND v.canonical_title NOT LIKE '%ApiKey=%'
|
||||
AND lower(v.canonical_title) NOT LIKE '%api key%'
|
||||
ORDER BY v.LAST_UPDATE_DATE DESC, v.video_id DESC
|
||||
LIMIT 1
|
||||
) AS linked_video_title
|
||||
FROM imm_anime a
|
||||
WHERE a.canonical_title LIKE '%api_key=%'
|
||||
WHERE a.canonical_title LIKE '%api_key=%' OR a.canonical_title LIKE '%ApiKey=%'
|
||||
OR lower(a.canonical_title) LIKE '%api key%'
|
||||
OR lower(a.normalized_title_key) LIKE '%api key%'
|
||||
`,
|
||||
@@ -244,11 +244,11 @@ function repairLeakedJellyfinVideoParseMetadata(
|
||||
LAST_UPDATE_DATE = ?
|
||||
WHERE source_type = 2
|
||||
AND (
|
||||
parsed_basename LIKE '%api_key=%'
|
||||
parsed_basename LIKE '%api_key=%' OR parsed_basename LIKE '%ApiKey=%'
|
||||
OR lower(parsed_basename) LIKE '%api key%'
|
||||
OR parsed_title LIKE '%api_key=%'
|
||||
OR parsed_title LIKE '%api_key=%' OR parsed_title LIKE '%ApiKey=%'
|
||||
OR lower(parsed_title) LIKE '%api key%'
|
||||
OR parse_metadata_json LIKE '%api_key=%'
|
||||
OR parse_metadata_json LIKE '%api_key=%' OR parse_metadata_json LIKE '%ApiKey=%'
|
||||
OR lower(parse_metadata_json) LIKE '%api key%'
|
||||
)
|
||||
`,
|
||||
@@ -267,7 +267,7 @@ function repairLeakedJellyfinAnimeParseMetadata(
|
||||
UPDATE imm_anime
|
||||
SET metadata_json = NULL, LAST_UPDATE_DATE = ?
|
||||
WHERE (
|
||||
metadata_json LIKE '%api_key=%'
|
||||
metadata_json LIKE '%api_key=%' OR metadata_json LIKE '%ApiKey=%'
|
||||
OR lower(metadata_json) LIKE '%api key%'
|
||||
) AND (
|
||||
lower(metadata_json) LIKE '%stream?%'
|
||||
@@ -295,11 +295,11 @@ export function repairJellyfinStreamVideoLinks(db: DatabaseSync): JellyfinLinkRe
|
||||
FROM imm_videos
|
||||
WHERE source_type = 2
|
||||
AND (
|
||||
video_key LIKE '%api_key=%'
|
||||
video_key LIKE '%api_key=%' OR video_key LIKE '%ApiKey=%'
|
||||
OR lower(video_key) LIKE '%api key%'
|
||||
OR source_url LIKE '%api_key=%'
|
||||
OR source_url LIKE '%api_key=%' OR source_url LIKE '%ApiKey=%'
|
||||
OR lower(source_url) LIKE '%api key%'
|
||||
OR canonical_title LIKE '%api_key=%'
|
||||
OR canonical_title LIKE '%api_key=%' OR canonical_title LIKE '%ApiKey=%'
|
||||
OR lower(canonical_title) LIKE '%api key%'
|
||||
)
|
||||
`,
|
||||
|
||||
@@ -4,6 +4,17 @@ import { buildJellyfinTimelinePayload, JellyfinRemoteSessionService } from './je
|
||||
|
||||
class FakeWebSocket {
|
||||
private listeners: Record<string, Array<(...args: unknown[]) => void>> = {};
|
||||
sent: string[] = [];
|
||||
terminated = false;
|
||||
|
||||
send(data: string): void {
|
||||
this.sent.push(data);
|
||||
}
|
||||
|
||||
terminate(): void {
|
||||
this.terminated = true;
|
||||
this.emit('close');
|
||||
}
|
||||
|
||||
on(event: string, listener: (...args: unknown[]) => void): this {
|
||||
if (!this.listeners[event]) {
|
||||
@@ -58,7 +69,7 @@ test('start posts capabilities on socket connect', async () => {
|
||||
accessToken: 'token-1',
|
||||
deviceId: 'device-1',
|
||||
webSocketFactory: (url) => {
|
||||
assert.equal(url, 'ws://jellyfin.local:8096/socket?api_key=token-1&deviceId=device-1');
|
||||
assert.equal(url, 'ws://jellyfin.local:8096/socket?ApiKey=token-1&deviceId=device-1');
|
||||
const socket = new FakeWebSocket();
|
||||
sockets.push(socket);
|
||||
return socket as unknown as any;
|
||||
@@ -99,7 +110,8 @@ test('socket headers include jellyfin authorization metadata', () => {
|
||||
assert.equal(seenHeaders.length, 1);
|
||||
assert.ok(seenHeaders[0]!['Authorization']!.includes('Client="SubMiner"'));
|
||||
assert.ok(seenHeaders[0]!['Authorization']!.includes('DeviceId="device-auth"'));
|
||||
assert.ok(seenHeaders[0]!['X-Emby-Authorization']);
|
||||
assert.equal('X-Emby-Authorization' in seenHeaders[0]!, false);
|
||||
assert.equal('X-Emby-Token' in seenHeaders[0]!, false);
|
||||
});
|
||||
|
||||
test('dispatches inbound Play, Playstate, and GeneralCommand messages', () => {
|
||||
@@ -355,3 +367,149 @@ test('advertiseNow validates server registration using Sessions endpoint', async
|
||||
assert.equal(ok, true);
|
||||
assert.ok(calls.some((url) => url.endsWith('/Sessions')));
|
||||
});
|
||||
|
||||
test('answers ForceKeepAlive with KeepAlive messages on the advertised cadence', () => {
|
||||
const sockets: FakeWebSocket[] = [];
|
||||
const timers: Array<{ handler: () => void; delay: number }> = [];
|
||||
|
||||
const service = new JellyfinRemoteSessionService({
|
||||
serverUrl: 'http://jellyfin.local',
|
||||
accessToken: 'token-ka',
|
||||
deviceId: 'device-ka',
|
||||
webSocketFactory: () => {
|
||||
const socket = new FakeWebSocket();
|
||||
sockets.push(socket);
|
||||
return socket as unknown as any;
|
||||
},
|
||||
fetchImpl: (async () => new Response(null, { status: 200 })) as typeof fetch,
|
||||
setTimer: ((handler: () => void, delay?: number) => {
|
||||
timers.push({ handler, delay: Number(delay) });
|
||||
return timers.length as unknown as ReturnType<typeof setTimeout>;
|
||||
}) as typeof setTimeout,
|
||||
clearTimer: (() => undefined) as typeof clearTimeout,
|
||||
});
|
||||
|
||||
service.start();
|
||||
sockets[0]!.emit('open');
|
||||
assert.deepEqual(sockets[0]!.sent, ['{"MessageType":"KeepAlive"}']);
|
||||
assert.equal(timers[0]!.delay, 30_000);
|
||||
|
||||
sockets[0]!.emit('message', JSON.stringify({ MessageType: 'ForceKeepAlive', Data: 20 }));
|
||||
assert.equal(sockets[0]!.sent.length, 2);
|
||||
assert.equal(timers.at(-1)!.delay, 10_000);
|
||||
|
||||
timers.at(-1)!.handler();
|
||||
assert.equal(sockets[0]!.sent.length, 3);
|
||||
});
|
||||
|
||||
test('reconnects when the server stops answering keep-alives', () => {
|
||||
let now = 1_000_000;
|
||||
const sockets: FakeWebSocket[] = [];
|
||||
const timers: Array<() => void> = [];
|
||||
const warnings: string[] = [];
|
||||
|
||||
const service = new JellyfinRemoteSessionService({
|
||||
serverUrl: 'http://jellyfin.local',
|
||||
accessToken: 'token-lost',
|
||||
deviceId: 'device-lost',
|
||||
webSocketFactory: () => {
|
||||
const socket = new FakeWebSocket();
|
||||
sockets.push(socket);
|
||||
return socket as unknown as any;
|
||||
},
|
||||
fetchImpl: (async () => new Response(null, { status: 200 })) as typeof fetch,
|
||||
getNow: () => now,
|
||||
logWarn: (message) => {
|
||||
warnings.push(message);
|
||||
},
|
||||
reconnectBaseDelayMs: 100,
|
||||
setTimer: ((handler: () => void) => {
|
||||
timers.push(handler);
|
||||
return timers.length as unknown as ReturnType<typeof setTimeout>;
|
||||
}) as typeof setTimeout,
|
||||
clearTimer: (() => undefined) as typeof clearTimeout,
|
||||
});
|
||||
|
||||
service.start();
|
||||
sockets[0]!.emit('open');
|
||||
|
||||
// Two silent ticks are still within the 90s tolerance; the third marks the socket lost.
|
||||
now += 30_000;
|
||||
timers.shift()!();
|
||||
now += 30_000;
|
||||
timers.shift()!();
|
||||
assert.equal(sockets[0]!.sent.length, 3);
|
||||
assert.equal(sockets[0]!.terminated, false);
|
||||
|
||||
now += 30_000;
|
||||
timers.shift()!();
|
||||
assert.equal(sockets[0]!.terminated, true);
|
||||
assert.equal(service.isConnected(), false);
|
||||
assert.equal(warnings.length, 1);
|
||||
|
||||
timers.shift()!();
|
||||
assert.equal(sockets.length, 2);
|
||||
});
|
||||
|
||||
test('warns once per failing timeline endpoint until it recovers', async () => {
|
||||
const warnings: string[] = [];
|
||||
let status = 400;
|
||||
|
||||
const service = new JellyfinRemoteSessionService({
|
||||
serverUrl: 'http://jellyfin.local',
|
||||
accessToken: 'token-warn',
|
||||
deviceId: 'device-warn',
|
||||
webSocketFactory: () => new FakeWebSocket() as unknown as any,
|
||||
fetchImpl: (async () => new Response(null, { status })) as typeof fetch,
|
||||
logWarn: (message) => {
|
||||
warnings.push(message);
|
||||
},
|
||||
});
|
||||
const state = { itemId: 'item-1', positionTicks: 10, playMethod: 'DirectPlay' };
|
||||
|
||||
assert.equal(await service.reportStopped(state), false);
|
||||
assert.equal(await service.reportStopped(state), false);
|
||||
assert.equal(warnings.length, 1);
|
||||
assert.match(warnings[0]!, /Sessions\/Playing\/Stopped/);
|
||||
|
||||
status = 200;
|
||||
assert.equal(await service.reportStopped(state), true);
|
||||
status = 500;
|
||||
assert.equal(await service.reportStopped(state), false);
|
||||
assert.equal(warnings.length, 2);
|
||||
});
|
||||
|
||||
test('ignores messages from a superseded socket', () => {
|
||||
const sockets: FakeWebSocket[] = [];
|
||||
const playPayloads: unknown[] = [];
|
||||
|
||||
const service = new JellyfinRemoteSessionService({
|
||||
serverUrl: 'http://jellyfin.local',
|
||||
accessToken: 'token-stale',
|
||||
deviceId: 'device-stale',
|
||||
webSocketFactory: () => {
|
||||
const socket = new FakeWebSocket();
|
||||
sockets.push(socket);
|
||||
return socket as unknown as any;
|
||||
},
|
||||
fetchImpl: (async () => new Response(null, { status: 200 })) as typeof fetch,
|
||||
onPlay: (payload) => {
|
||||
playPayloads.push(payload);
|
||||
},
|
||||
setTimer: (() => 1 as unknown as ReturnType<typeof setTimeout>) as unknown as typeof setTimeout,
|
||||
clearTimer: (() => undefined) as typeof clearTimeout,
|
||||
});
|
||||
|
||||
service.start();
|
||||
service.stop();
|
||||
service.start();
|
||||
sockets[1]!.emit('open');
|
||||
assert.equal(sockets.length, 2);
|
||||
|
||||
sockets[0]!.emit('message', JSON.stringify({ MessageType: 'ForceKeepAlive', Data: 10 }));
|
||||
sockets[0]!.emit('message', JSON.stringify({ MessageType: 'Play', Data: { ItemIds: ['x'] } }));
|
||||
|
||||
assert.deepEqual(sockets[0]!.sent, []);
|
||||
assert.deepEqual(playPayloads, []);
|
||||
assert.deepEqual(sockets[1]!.sent, ['{"MessageType":"KeepAlive"}']);
|
||||
});
|
||||
|
||||
@@ -45,9 +45,22 @@ interface JellyfinRemoteSocket {
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'error', listener: (error: Error) => void): this;
|
||||
on(event: 'message', listener: (data: unknown) => void): this;
|
||||
send(data: string): void;
|
||||
terminate?(): void;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
// Jellyfin advertises its keep-alive timeout in the ForceKeepAlive message (60s by default),
|
||||
// drops sockets that stay silent past it, and since 12.0 also detaches the session's remote
|
||||
// controller when that happens. The drop never reaches the client as a close frame, so the
|
||||
// client has to keep sending KeepAlive and treat missing replies as a dead connection.
|
||||
const DEFAULT_KEEP_ALIVE_TIMEOUT_MS = 60_000;
|
||||
const KEEP_ALIVE_LOST_FACTOR = 1.5;
|
||||
|
||||
function unrefTimer(timer: ReturnType<typeof setTimeout>): void {
|
||||
(timer as unknown as { unref?: () => void }).unref?.();
|
||||
}
|
||||
|
||||
type JellyfinRemoteSocketHeaders = Record<string, string>;
|
||||
|
||||
export interface JellyfinRemoteSessionServiceOptions {
|
||||
@@ -77,6 +90,9 @@ export interface JellyfinRemoteSessionServiceOptions {
|
||||
deviceName?: string;
|
||||
onConnected?: () => void;
|
||||
onDisconnected?: () => void;
|
||||
logWarn?: (message: string, details?: unknown) => void;
|
||||
keepAliveTimeoutMs?: number;
|
||||
getNow?: () => number;
|
||||
}
|
||||
|
||||
function normalizeServerUrl(serverUrl: string): string {
|
||||
@@ -196,6 +212,12 @@ export class JellyfinRemoteSessionService {
|
||||
private readonly authHeader: string;
|
||||
private readonly onConnected?: () => void;
|
||||
private readonly onDisconnected?: () => void;
|
||||
private readonly logWarn?: (message: string, details?: unknown) => void;
|
||||
private readonly now: () => number;
|
||||
private keepAliveTimeoutMs: number;
|
||||
private keepAliveTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private lastInboundAtMs = 0;
|
||||
private readonly failedRequestPaths = new Set<string>();
|
||||
|
||||
private readonly reconnectBaseDelayMs: number;
|
||||
private readonly reconnectMaxDelayMs: number;
|
||||
@@ -233,6 +255,12 @@ export class JellyfinRemoteSessionService {
|
||||
});
|
||||
this.onConnected = options.onConnected;
|
||||
this.onDisconnected = options.onDisconnected;
|
||||
this.logWarn = options.logWarn;
|
||||
this.now = options.getNow ?? Date.now;
|
||||
this.keepAliveTimeoutMs = Math.max(
|
||||
1000,
|
||||
options.keepAliveTimeoutMs ?? DEFAULT_KEEP_ALIVE_TIMEOUT_MS,
|
||||
);
|
||||
this.reconnectBaseDelayMs = Math.max(100, options.reconnectBaseDelayMs ?? 500);
|
||||
this.reconnectMaxDelayMs = Math.max(
|
||||
this.reconnectBaseDelayMs,
|
||||
@@ -250,6 +278,7 @@ export class JellyfinRemoteSessionService {
|
||||
public stop(): void {
|
||||
this.running = false;
|
||||
this.connected = false;
|
||||
this.stopKeepAlive();
|
||||
if (this.reconnectTimer) {
|
||||
this.clearTimer(this.reconnectTimer);
|
||||
this.reconnectTimer = null;
|
||||
@@ -298,12 +327,16 @@ export class JellyfinRemoteSessionService {
|
||||
if (this.socket !== socket || !this.running) return;
|
||||
this.connected = true;
|
||||
this.reconnectAttempt = 0;
|
||||
this.lastInboundAtMs = this.now();
|
||||
this.startKeepAlive(socket, this.keepAliveTimeoutMs);
|
||||
this.onConnected?.();
|
||||
void this.postCapabilities();
|
||||
});
|
||||
|
||||
socket.on('message', (rawData) => {
|
||||
this.handleInboundMessage(rawData);
|
||||
if (this.socket !== socket || !this.running) return;
|
||||
this.lastInboundAtMs = this.now();
|
||||
this.handleInboundMessage(socket, rawData);
|
||||
});
|
||||
|
||||
const handleDisconnect = () => {
|
||||
@@ -311,6 +344,7 @@ export class JellyfinRemoteSessionService {
|
||||
disconnected = true;
|
||||
if (this.socket === socket) {
|
||||
this.socket = null;
|
||||
this.stopKeepAlive();
|
||||
}
|
||||
this.connected = false;
|
||||
this.onDisconnected?.();
|
||||
@@ -323,6 +357,51 @@ export class JellyfinRemoteSessionService {
|
||||
socket.on('error', handleDisconnect);
|
||||
}
|
||||
|
||||
private startKeepAlive(socket: JellyfinRemoteSocket, timeoutMs: number): void {
|
||||
this.stopKeepAlive();
|
||||
this.keepAliveTimeoutMs = timeoutMs;
|
||||
this.sendKeepAlive(socket);
|
||||
this.scheduleKeepAliveTick(socket);
|
||||
}
|
||||
|
||||
private scheduleKeepAliveTick(socket: JellyfinRemoteSocket): void {
|
||||
const intervalMs = Math.max(1000, Math.floor(this.keepAliveTimeoutMs / 2));
|
||||
const timer = this.setTimer(() => {
|
||||
this.keepAliveTimer = null;
|
||||
if (this.socket !== socket || !this.running) return;
|
||||
const silentForMs = this.now() - this.lastInboundAtMs;
|
||||
if (silentForMs >= this.keepAliveTimeoutMs * KEEP_ALIVE_LOST_FACTOR) {
|
||||
this.logWarn?.('Jellyfin remote websocket stopped answering keep-alives; reconnecting.');
|
||||
// Dropping the socket raises 'close', which schedules the reconnect.
|
||||
if (socket.terminate) {
|
||||
socket.terminate();
|
||||
} else {
|
||||
socket.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.sendKeepAlive(socket);
|
||||
this.scheduleKeepAliveTick(socket);
|
||||
}, intervalMs);
|
||||
unrefTimer(timer);
|
||||
this.keepAliveTimer = timer;
|
||||
}
|
||||
|
||||
private stopKeepAlive(): void {
|
||||
if (this.keepAliveTimer) {
|
||||
this.clearTimer(this.keepAliveTimer);
|
||||
this.keepAliveTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private sendKeepAlive(socket: JellyfinRemoteSocket): void {
|
||||
try {
|
||||
socket.send(JSON.stringify({ MessageType: 'KeepAlive' }));
|
||||
} catch (error) {
|
||||
this.logWarn?.('Failed to send Jellyfin remote keep-alive.', error);
|
||||
}
|
||||
}
|
||||
|
||||
private scheduleReconnect(): void {
|
||||
const delay = Math.min(
|
||||
this.reconnectMaxDelayMs,
|
||||
@@ -342,7 +421,7 @@ export class JellyfinRemoteSessionService {
|
||||
const baseUrl = new URL(`${this.serverUrl}/`);
|
||||
const socketUrl = new URL('/socket', baseUrl);
|
||||
socketUrl.protocol = baseUrl.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
socketUrl.searchParams.set('api_key', this.accessToken);
|
||||
socketUrl.searchParams.set('ApiKey', this.accessToken);
|
||||
socketUrl.searchParams.set('deviceId', this.deviceId);
|
||||
return socketUrl.toString();
|
||||
}
|
||||
@@ -350,8 +429,6 @@ export class JellyfinRemoteSessionService {
|
||||
private createSocket(url: string): JellyfinRemoteSocket {
|
||||
const headers: JellyfinRemoteSocketHeaders = {
|
||||
Authorization: this.authHeader,
|
||||
'X-Emby-Authorization': this.authHeader,
|
||||
'X-Emby-Token': this.accessToken,
|
||||
};
|
||||
if (this.socketHeadersFactory) {
|
||||
return this.socketHeadersFactory(url, headers);
|
||||
@@ -375,8 +452,6 @@ export class JellyfinRemoteSessionService {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: this.authHeader,
|
||||
'X-Emby-Authorization': this.authHeader,
|
||||
'X-Emby-Token': this.accessToken,
|
||||
},
|
||||
});
|
||||
if (!response.ok) return false;
|
||||
@@ -398,21 +473,41 @@ export class JellyfinRemoteSessionService {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: this.authHeader,
|
||||
'X-Emby-Authorization': this.authHeader,
|
||||
'X-Emby-Token': this.accessToken,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
this.noteRequestOutcome(path, response.ok ? null : `HTTP ${response.status}`);
|
||||
return response.ok;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
this.noteRequestOutcome(path, error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private handleInboundMessage(rawData: unknown): void {
|
||||
// Warn once per path while it keeps failing so a rejected stop report is visible in the
|
||||
// log without a warning per progress tick.
|
||||
private noteRequestOutcome(path: string, failure: unknown): void {
|
||||
if (failure === null) {
|
||||
this.failedRequestPaths.delete(path);
|
||||
return;
|
||||
}
|
||||
if (this.failedRequestPaths.has(path)) return;
|
||||
this.failedRequestPaths.add(path);
|
||||
this.logWarn?.(`Jellyfin remote request failed: POST ${path}`, failure);
|
||||
}
|
||||
|
||||
private handleInboundMessage(socket: JellyfinRemoteSocket, rawData: unknown): void {
|
||||
const message = parseInboundMessage(rawData);
|
||||
if (!message) return;
|
||||
const messageType = message.MessageType;
|
||||
if (messageType === 'ForceKeepAlive') {
|
||||
const seconds = Number(message.Data);
|
||||
const timeoutMs =
|
||||
Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : this.keepAliveTimeoutMs;
|
||||
this.startKeepAlive(socket, timeoutMs);
|
||||
return;
|
||||
}
|
||||
if (messageType === 'KeepAlive') return;
|
||||
const payload = parseMessageData(message.Data);
|
||||
if (messageType === 'Play') {
|
||||
this.onPlay?.(payload);
|
||||
|
||||
@@ -279,7 +279,7 @@ test('resolvePlaybackPlan prefers transcode when directPlayPreferred is disabled
|
||||
assert.equal(plan.mode, 'transcode');
|
||||
const url = new URL(plan.url);
|
||||
assert.match(url.pathname, /\/Videos\/movie-2\/master\.m3u8$/);
|
||||
assert.equal(url.searchParams.get('api_key'), 'token');
|
||||
assert.equal(url.searchParams.get('ApiKey'), 'token');
|
||||
assert.equal(url.searchParams.get('AudioStreamIndex'), '4');
|
||||
assert.equal(url.searchParams.get('StartTimeTicks'), '10000000');
|
||||
} finally {
|
||||
@@ -365,7 +365,7 @@ test('listSubtitleTracks returns all subtitle streams with delivery urls', async
|
||||
IsForced: true,
|
||||
IsExternal: true,
|
||||
DeliveryMethod: 'External',
|
||||
DeliveryUrl: '/Videos/movie-1/ms-1/Subtitles/3/Stream.srt',
|
||||
DeliveryUrl: '/Videos/movie-1/ms-1/Subtitles/3/Stream.srt?api_key=server-token',
|
||||
IsExternalUrl: false,
|
||||
},
|
||||
{
|
||||
@@ -402,11 +402,11 @@ test('listSubtitleTracks returns all subtitle streams with delivery urls', async
|
||||
);
|
||||
assert.equal(
|
||||
tracks[0]!.deliveryUrl,
|
||||
'http://jellyfin.local/Videos/movie-1/ms-1/Subtitles/2/Stream.srt?api_key=token',
|
||||
'http://jellyfin.local/Videos/movie-1/ms-1/Subtitles/2/Stream.srt?ApiKey=token',
|
||||
);
|
||||
assert.equal(
|
||||
tracks[1]!.deliveryUrl,
|
||||
'http://jellyfin.local/Videos/movie-1/ms-1/Subtitles/3/Stream.srt?api_key=token',
|
||||
'http://jellyfin.local/Videos/movie-1/ms-1/Subtitles/3/Stream.srt?ApiKey=token',
|
||||
);
|
||||
assert.equal(tracks[2]!.deliveryUrl, 'https://cdn.example.com/subs.srt');
|
||||
} finally {
|
||||
@@ -505,7 +505,7 @@ test('resolvePlaybackPlan reuses server transcoding url and appends missing para
|
||||
const url = new URL(plan.url);
|
||||
assert.match(url.pathname, /\/Videos\/movie-4\/master\.m3u8$/);
|
||||
assert.equal(url.searchParams.get('VideoCodec'), 'hevc');
|
||||
assert.equal(url.searchParams.get('api_key'), 'token');
|
||||
assert.equal(url.searchParams.get('ApiKey'), 'token');
|
||||
assert.equal(url.searchParams.get('AudioStreamIndex'), '3');
|
||||
assert.equal(url.searchParams.get('SubtitleStreamIndex'), '8');
|
||||
assert.equal(url.searchParams.get('StartTimeTicks'), '50000000');
|
||||
@@ -626,7 +626,7 @@ test('listSubtitleTracks falls back from PlaybackInfo to item media sources', as
|
||||
assert.equal(tracks[0]!.index, 11);
|
||||
assert.equal(
|
||||
tracks[0]!.deliveryUrl,
|
||||
'http://jellyfin.local/Videos/movie-fallback/ms-fallback/Subtitles/11/Stream.srt?api_key=token',
|
||||
'http://jellyfin.local/Videos/movie-fallback/ms-fallback/Subtitles/11/Stream.srt?ApiKey=token',
|
||||
);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
@@ -789,3 +789,67 @@ test('resolvePlaybackPlan surfaces no-source and no-stream fallback errors', asy
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
||||
test('API requests authenticate with the MediaBrowser header only (no legacy X-Emby-Token)', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
const seenHeaders: Headers[] = [];
|
||||
globalThis.fetch = (async (_input, init) => {
|
||||
seenHeaders.push(new Headers(init?.headers));
|
||||
return new Response(JSON.stringify({ Items: [] }), { status: 200 });
|
||||
}) as typeof fetch;
|
||||
|
||||
try {
|
||||
await listLibraries(
|
||||
{ serverUrl: 'http://jellyfin.local', accessToken: 'token', userId: 'u1', username: 'kyle' },
|
||||
clientInfo,
|
||||
);
|
||||
assert.equal(seenHeaders.length, 1);
|
||||
const headers = seenHeaders[0]!;
|
||||
const authorization = headers.get('authorization') ?? '';
|
||||
assert.match(authorization, /^MediaBrowser /);
|
||||
assert.match(authorization, /Token="token"/);
|
||||
assert.match(authorization, /DeviceId="subminer-test"/);
|
||||
assert.equal(headers.has('x-emby-token'), false);
|
||||
assert.equal(headers.has('x-emby-authorization'), false);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
||||
test('resolvePlaybackPlan replaces a legacy api_key on the server transcoding url with ApiKey', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = (async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
Id: 'movie-legacy',
|
||||
Name: 'Movie Legacy',
|
||||
MediaSources: [
|
||||
{
|
||||
Id: 'ms-legacy',
|
||||
Container: 'mkv',
|
||||
SupportsDirectStream: false,
|
||||
SupportsTranscoding: true,
|
||||
TranscodingUrl: '/Videos/movie-legacy/master.m3u8?VideoCodec=hevc&api_key=server-token',
|
||||
},
|
||||
],
|
||||
}),
|
||||
{ status: 200 },
|
||||
)) as typeof fetch;
|
||||
|
||||
try {
|
||||
const plan = await resolvePlaybackPlan(
|
||||
{ serverUrl: 'http://jellyfin.local', accessToken: 'token', userId: 'u1', username: 'kyle' },
|
||||
clientInfo,
|
||||
{ enabled: true, directPlayPreferred: true },
|
||||
{ itemId: 'movie-legacy' },
|
||||
);
|
||||
|
||||
assert.equal(plan.mode, 'transcode');
|
||||
const url = new URL(plan.url);
|
||||
assert.equal(url.searchParams.get('ApiKey'), 'token');
|
||||
assert.equal(url.searchParams.has('api_key'), false);
|
||||
assert.equal(url.searchParams.get('VideoCodec'), 'hevc');
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,6 +136,16 @@ function getErrorMessage(error: unknown): string {
|
||||
return String(error || 'unknown error');
|
||||
}
|
||||
|
||||
// Jellyfin reads query keys case-insensitively and older servers embed the token as
|
||||
// `api_key` in the URLs they hand back, so drop every spelling before setting the one
|
||||
// form Jellyfin 12 still accepts with legacy authorization disabled.
|
||||
function setApiKeyParam(url: URL, accessToken: string): void {
|
||||
for (const key of [...url.searchParams.keys()]) {
|
||||
if (/^api_?key$/i.test(key)) url.searchParams.delete(key);
|
||||
}
|
||||
url.searchParams.set('ApiKey', accessToken);
|
||||
}
|
||||
|
||||
function resolveDeliveryUrl(
|
||||
session: JellyfinAuthSession,
|
||||
stream: JellyfinMediaStream,
|
||||
@@ -146,9 +156,7 @@ function resolveDeliveryUrl(
|
||||
if (deliveryUrl) {
|
||||
if (stream.IsExternalUrl === true) return deliveryUrl;
|
||||
const resolved = new URL(deliveryUrl, `${session.serverUrl}/`);
|
||||
if (!resolved.searchParams.has('api_key')) {
|
||||
resolved.searchParams.set('api_key', session.accessToken);
|
||||
}
|
||||
setApiKeyParam(resolved, session.accessToken);
|
||||
return resolved.toString();
|
||||
}
|
||||
|
||||
@@ -171,9 +179,7 @@ function resolveDeliveryUrl(
|
||||
`/Videos/${encodeURIComponent(itemId)}/${encodeURIComponent(mediaSourceId)}/Subtitles/${streamIndex}/Stream.${ext}`,
|
||||
`${session.serverUrl}/`,
|
||||
);
|
||||
if (!fallback.searchParams.has('api_key')) {
|
||||
fallback.searchParams.set('api_key', session.accessToken);
|
||||
}
|
||||
setApiKeyParam(fallback, session.accessToken);
|
||||
return fallback.toString();
|
||||
}
|
||||
|
||||
@@ -197,7 +203,6 @@ async function jellyfinRequestJson<T>(
|
||||
const headers = new Headers(init.headers ?? {});
|
||||
headers.set('Content-Type', 'application/json');
|
||||
headers.set('Authorization', createAuthorizationHeader(client, session.accessToken));
|
||||
headers.set('X-Emby-Token', session.accessToken);
|
||||
|
||||
const response = await fetch(`${session.serverUrl}${path}`, {
|
||||
...init,
|
||||
@@ -221,7 +226,7 @@ function createDirectPlayUrl(
|
||||
): string {
|
||||
const query = new URLSearchParams({
|
||||
static: 'true',
|
||||
api_key: session.accessToken,
|
||||
ApiKey: session.accessToken,
|
||||
MediaSourceId: ensureString(mediaSource.Id),
|
||||
});
|
||||
if (mediaSource.LiveStreamId) {
|
||||
@@ -245,9 +250,7 @@ function createTranscodeUrl(
|
||||
): string {
|
||||
if (mediaSource.TranscodingUrl) {
|
||||
const url = new URL(`${session.serverUrl}${mediaSource.TranscodingUrl}`);
|
||||
if (!url.searchParams.has('api_key')) {
|
||||
url.searchParams.set('api_key', session.accessToken);
|
||||
}
|
||||
setApiKeyParam(url, session.accessToken);
|
||||
if (!url.searchParams.has('AudioStreamIndex') && plan.audioStreamIndex !== null) {
|
||||
url.searchParams.set('AudioStreamIndex', String(plan.audioStreamIndex));
|
||||
}
|
||||
@@ -261,7 +264,7 @@ function createTranscodeUrl(
|
||||
}
|
||||
|
||||
const query = new URLSearchParams({
|
||||
api_key: session.accessToken,
|
||||
ApiKey: session.accessToken,
|
||||
MediaSourceId: ensureString(mediaSource.Id),
|
||||
VideoCodec: ensureString(config.transcodeVideoCodec, 'h264'),
|
||||
TranscodingContainer: 'ts',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
MPV_REQUEST_ID_AID,
|
||||
MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
MPV_REQUEST_ID_OSD_DIMENSIONS,
|
||||
MPV_REQUEST_ID_OSD_HEIGHT,
|
||||
MPV_REQUEST_ID_PATH,
|
||||
@@ -85,6 +86,7 @@ const MPV_INITIAL_PROPERTY_REQUESTS: Array<MpvProtocolCommand> = [
|
||||
},
|
||||
{
|
||||
command: ['get_property', 'media-title'],
|
||||
request_id: MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
},
|
||||
{
|
||||
command: ['get_property', 'pause'],
|
||||
|
||||
@@ -35,6 +35,7 @@ export const MPV_REQUEST_ID_SUB_USE_MARGINS = 122;
|
||||
export const MPV_REQUEST_ID_PAUSE = 123;
|
||||
export const MPV_REQUEST_ID_TRACK_LIST_SECONDARY = 200;
|
||||
export const MPV_REQUEST_ID_TRACK_LIST_AUDIO = 201;
|
||||
export const MPV_REQUEST_ID_MEDIA_TITLE = 202;
|
||||
|
||||
export type MpvMessageParser = (message: MpvMessage) => void;
|
||||
export type MpvParseErrorHandler = (line: string, error: unknown) => void;
|
||||
@@ -335,14 +336,18 @@ export async function dispatchMpvProtocolMessage(
|
||||
} else if (msg.name === 'fullscreen') {
|
||||
deps.emitFullscreenChange({ fullscreen: asBoolean(msg.data, false) });
|
||||
} else if (msg.name === 'media-title') {
|
||||
const title = typeof msg.data === 'string' ? sanitizeMediaTitle(msg.data) : null;
|
||||
if (typeof msg.data === 'string' && msg.data.trim() && !title) return;
|
||||
deps.emitMediaTitleChange({
|
||||
title,
|
||||
});
|
||||
applyMediaTitle(deps, msg.data);
|
||||
} else if (msg.name === 'path') {
|
||||
const path = (msg.data as string) || '';
|
||||
deps.setCurrentVideoPath(path);
|
||||
// A forced title set before loadfile arrives ahead of the path change that clears the
|
||||
// cached title and never fires again, so read it back once the new path is known.
|
||||
if (path) {
|
||||
deps.sendCommand({
|
||||
command: ['get_property', 'media-title'],
|
||||
request_id: MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
});
|
||||
}
|
||||
deps.emitMediaPathChange({ path });
|
||||
deps.autoLoadSecondarySubTrack(path);
|
||||
deps.syncCurrentAudioStreamIndex();
|
||||
@@ -467,6 +472,8 @@ export async function dispatchMpvProtocolMessage(
|
||||
deps.emitSubtitleAssChange({ text: (msg.data as string) || '' });
|
||||
} else if (msg.request_id === MPV_REQUEST_ID_PATH) {
|
||||
deps.emitMediaPathChange({ path: (msg.data as string) || '' });
|
||||
} else if (msg.request_id === MPV_REQUEST_ID_MEDIA_TITLE) {
|
||||
applyMediaTitle(deps, msg.data);
|
||||
} else if (msg.request_id === MPV_REQUEST_ID_AID) {
|
||||
deps.setCurrentAudioTrackId(typeof msg.data === 'number' ? (msg.data as number) : null);
|
||||
deps.syncCurrentAudioStreamIndex();
|
||||
@@ -557,6 +564,17 @@ export function asFiniteNumber(value: unknown, fallback: number): number {
|
||||
return Number.isFinite(nextValue) ? nextValue : fallback;
|
||||
}
|
||||
|
||||
// URL-derived titles (mpv falls back to the basename of a query-bearing stream URL) must not
|
||||
// replace known metadata, so they are dropped instead of cached.
|
||||
function applyMediaTitle(
|
||||
deps: Pick<MpvProtocolHandleMessageDeps, 'emitMediaTitleChange'>,
|
||||
data: unknown,
|
||||
): void {
|
||||
const title = typeof data === 'string' ? sanitizeMediaTitle(data) : null;
|
||||
if (typeof data === 'string' && data.trim() && !title) return;
|
||||
deps.emitMediaTitleChange({ title });
|
||||
}
|
||||
|
||||
export function parseVisibilityProperty(value: unknown): boolean | null {
|
||||
if (typeof value === 'boolean') return value;
|
||||
if (typeof value !== 'string') return null;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from './mpv';
|
||||
import {
|
||||
MPV_REQUEST_ID_TRACK_LIST_AUDIO,
|
||||
MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
MPV_REQUEST_ID_TRACK_LIST_SECONDARY,
|
||||
} from './mpv-protocol';
|
||||
|
||||
@@ -135,9 +136,15 @@ test('MpvIpcClient ignores URL-derived titles without replacing known metadata',
|
||||
assert.deepEqual(titles, ['My Anime S01E02']);
|
||||
});
|
||||
|
||||
test('MpvIpcClient clears cached media title when media path changes', async () => {
|
||||
test('MpvIpcClient clears cached media title when media path changes and reads it back', async () => {
|
||||
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
|
||||
const commands: Array<{ command?: unknown[]; request_id?: number }> = [];
|
||||
(client as any).send = (command: { command?: unknown[]; request_id?: number }) => {
|
||||
commands.push(command);
|
||||
return true;
|
||||
};
|
||||
|
||||
// A forced title (Jellyfin sets force-media-title before loadfile) arrives before the path.
|
||||
await invokeHandleMessage(client, {
|
||||
event: 'property-change',
|
||||
name: 'media-title',
|
||||
@@ -148,11 +155,33 @@ test('MpvIpcClient clears cached media title when media path changes', async ()
|
||||
await invokeHandleMessage(client, {
|
||||
event: 'property-change',
|
||||
name: 'path',
|
||||
data: '/tmp/new-episode.mkv',
|
||||
data: 'http://pve-main:8096/Videos/item/stream?static=true&ApiKey=secret',
|
||||
});
|
||||
|
||||
assert.equal(client.currentVideoPath, '/tmp/new-episode.mkv');
|
||||
assert.equal(
|
||||
client.currentVideoPath,
|
||||
'http://pve-main:8096/Videos/item/stream?static=true&ApiKey=secret',
|
||||
);
|
||||
assert.equal(client.currentMediaTitle, null);
|
||||
const titleRequest = commands.find(
|
||||
(command) => command.command?.[0] === 'get_property' && command.command?.[1] === 'media-title',
|
||||
);
|
||||
assert.equal(titleRequest?.request_id, MPV_REQUEST_ID_MEDIA_TITLE);
|
||||
|
||||
await invokeHandleMessage(client, {
|
||||
request_id: MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
error: 'success',
|
||||
data: '[Jellyfin/direct] Episode 1',
|
||||
});
|
||||
assert.equal(client.currentMediaTitle, '[Jellyfin/direct] Episode 1');
|
||||
|
||||
// A URL-derived read-back must not poison the cache.
|
||||
await invokeHandleMessage(client, {
|
||||
request_id: MPV_REQUEST_ID_MEDIA_TITLE,
|
||||
error: 'success',
|
||||
data: 'stream?static=true&ApiKey=secret',
|
||||
});
|
||||
assert.equal(client.currentMediaTitle, '[Jellyfin/direct] Episode 1');
|
||||
});
|
||||
|
||||
test('MpvIpcClient skips secondary subtitle autoload when media path is managed', async () => {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
createHandleJellyfinRemoteGeneralCommand,
|
||||
createHandleJellyfinRemotePlay,
|
||||
createHandleJellyfinRemotePlaystate,
|
||||
createJellyfinRemoteReportTracker,
|
||||
createReportJellyfinRemoteProgressHandler,
|
||||
createReportJellyfinRemoteStoppedHandler,
|
||||
} from '../domains/jellyfin';
|
||||
@@ -91,13 +92,17 @@ export function composeJellyfinRemoteHandlers(
|
||||
getNow: options.getNow,
|
||||
ticksPerSecond: options.ticksPerSecond,
|
||||
logDebug: options.logDebug,
|
||||
logWarn: options.logWarn,
|
||||
});
|
||||
const reportJellyfinRemoteProgress = createReportJellyfinRemoteProgressHandler(
|
||||
buildReportJellyfinRemoteProgressMainDepsHandler(),
|
||||
);
|
||||
const reportJellyfinRemoteStopped = createReportJellyfinRemoteStoppedHandler(
|
||||
buildReportJellyfinRemoteStoppedMainDepsHandler(),
|
||||
);
|
||||
const reportTracker = createJellyfinRemoteReportTracker();
|
||||
const reportJellyfinRemoteProgress = createReportJellyfinRemoteProgressHandler({
|
||||
...buildReportJellyfinRemoteProgressMainDepsHandler(),
|
||||
reportTracker,
|
||||
});
|
||||
const reportJellyfinRemoteStopped = createReportJellyfinRemoteStoppedHandler({
|
||||
...buildReportJellyfinRemoteStoppedMainDepsHandler(),
|
||||
reportTracker,
|
||||
});
|
||||
|
||||
const buildHandleJellyfinRemotePlayMainDepsHandler =
|
||||
createBuildHandleJellyfinRemotePlayMainDepsHandler({
|
||||
|
||||
@@ -75,5 +75,6 @@ export function createBuildReportJellyfinRemoteStoppedMainDepsHandler(
|
||||
getNow: deps.getNow ? () => deps.getNow?.() ?? Date.now() : undefined,
|
||||
ticksPerSecond: deps.ticksPerSecond,
|
||||
logDebug: (message: string, error: unknown) => deps.logDebug(message, error),
|
||||
...(deps.logWarn ? { logWarn: (message: string) => deps.logWarn?.(message) } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
markJellyfinRemotePlaybackLoaded,
|
||||
createJellyfinRemoteReportTracker,
|
||||
createReportJellyfinRemoteProgressHandler,
|
||||
createReportJellyfinRemoteStoppedHandler,
|
||||
secondsToJellyfinTicks,
|
||||
@@ -528,3 +529,70 @@ test('createReportJellyfinRemoteStoppedHandler ignores startup stop churn before
|
||||
assert.equal(stopped, false);
|
||||
assert.equal(cleared, false);
|
||||
});
|
||||
|
||||
test('createReportJellyfinRemoteStoppedHandler clears playback before reporting and waits for in-flight progress', async () => {
|
||||
const tracker = createJellyfinRemoteReportTracker();
|
||||
let playback: { itemId: string; playMethod: 'DirectPlay'; loadedMediaPath: string } | null = {
|
||||
itemId: 'item-1',
|
||||
playMethod: 'DirectPlay',
|
||||
loadedMediaPath: 'http://pve-main:8096/Videos/item-1/stream',
|
||||
};
|
||||
const calls: string[] = [];
|
||||
let releaseProgress: () => void = () => undefined;
|
||||
const progressGate = new Promise<void>((resolve) => {
|
||||
releaseProgress = resolve;
|
||||
});
|
||||
const session = {
|
||||
isConnected: () => true,
|
||||
reportProgress: async ({ eventName }: { eventName: string }) => {
|
||||
calls.push(`progress:${eventName}:${playback ? 'active' : 'cleared'}`);
|
||||
if (calls.length === 1) await progressGate;
|
||||
return true;
|
||||
},
|
||||
reportStopped: async () => {
|
||||
calls.push(`stopped:${playback ? 'active' : 'cleared'}`);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
const shared = {
|
||||
getActivePlayback: () => playback,
|
||||
clearActivePlayback: () => {
|
||||
playback = null;
|
||||
},
|
||||
getSession: () => session,
|
||||
getMpvClient: () => ({ currentTimePos: 42 }),
|
||||
ticksPerSecond: 10_000_000,
|
||||
logDebug: () => undefined,
|
||||
reportTracker: tracker,
|
||||
};
|
||||
const reportProgress = createReportJellyfinRemoteProgressHandler({
|
||||
...shared,
|
||||
getNow: () => 10_000,
|
||||
getLastProgressAtMs: () => 0,
|
||||
setLastProgressAtMs: () => undefined,
|
||||
progressIntervalMs: 3000,
|
||||
});
|
||||
const reportStopped = createReportJellyfinRemoteStoppedHandler(shared);
|
||||
|
||||
// A periodic tick is mid-request when the stop starts.
|
||||
const tick = reportProgress(true);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.deepEqual(calls, ['progress:TimeUpdate:active']);
|
||||
const stop = reportStopped();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.equal(playback, null);
|
||||
assert.deepEqual(calls, ['progress:TimeUpdate:active']);
|
||||
|
||||
// A tick fired after the stop began must not report anything.
|
||||
await reportProgress(true);
|
||||
assert.deepEqual(calls, ['progress:TimeUpdate:active']);
|
||||
|
||||
releaseProgress();
|
||||
await tick;
|
||||
await stop;
|
||||
assert.deepEqual(calls, [
|
||||
'progress:TimeUpdate:active',
|
||||
'progress:TimeUpdate:cleared',
|
||||
'stopped:cleared',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -134,6 +134,29 @@ function isSeekLikePositionJump(
|
||||
return Math.abs(nextPositionSeconds - previousPositionSeconds) >= thresholdSeconds;
|
||||
}
|
||||
|
||||
// Jellyfin re-creates a session's NowPlayingItem from any progress report, so a progress
|
||||
// tick that lands after the stop report leaves the server showing playback forever. The
|
||||
// tracker lets the stop handler wait for reports that are already in flight.
|
||||
export type JellyfinRemoteReportTracker = {
|
||||
track: (report: Promise<void>) => void;
|
||||
settled: () => Promise<void>;
|
||||
};
|
||||
|
||||
export function createJellyfinRemoteReportTracker(): JellyfinRemoteReportTracker {
|
||||
const active = new Set<Promise<void>>();
|
||||
return {
|
||||
track: (report) => {
|
||||
active.add(report);
|
||||
void report.finally(() => active.delete(report));
|
||||
},
|
||||
settled: async () => {
|
||||
while (active.size > 0) {
|
||||
await Promise.allSettled([...active]);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export type JellyfinRemoteProgressReporterDeps = {
|
||||
getActivePlayback: () => ActiveJellyfinRemotePlaybackState | null;
|
||||
clearActivePlayback: () => void;
|
||||
@@ -145,6 +168,7 @@ export type JellyfinRemoteProgressReporterDeps = {
|
||||
progressIntervalMs: number;
|
||||
ticksPerSecond: number;
|
||||
logDebug: (message: string, error: unknown) => void;
|
||||
reportTracker?: JellyfinRemoteReportTracker;
|
||||
};
|
||||
|
||||
export function createReportJellyfinRemoteProgressHandler(
|
||||
@@ -152,7 +176,7 @@ export function createReportJellyfinRemoteProgressHandler(
|
||||
) {
|
||||
let lastReportedPositionSeconds: number | null = null;
|
||||
|
||||
return async (force = false): Promise<void> => {
|
||||
const report = async (force: boolean): Promise<void> => {
|
||||
const playback = deps.getActivePlayback();
|
||||
if (!playback) return;
|
||||
const session = deps.getSession();
|
||||
@@ -193,6 +217,12 @@ export function createReportJellyfinRemoteProgressHandler(
|
||||
deps.logDebug('Failed to report Jellyfin remote progress', error);
|
||||
}
|
||||
};
|
||||
|
||||
return async (force = false): Promise<void> => {
|
||||
const pending = report(force);
|
||||
deps.reportTracker?.track(pending);
|
||||
await pending;
|
||||
};
|
||||
}
|
||||
|
||||
export type JellyfinRemoteStoppedReporterDeps = {
|
||||
@@ -203,6 +233,8 @@ export type JellyfinRemoteStoppedReporterDeps = {
|
||||
getNow?: () => number;
|
||||
ticksPerSecond: number;
|
||||
logDebug: (message: string, error: unknown) => void;
|
||||
logWarn?: (message: string) => void;
|
||||
reportTracker?: JellyfinRemoteReportTracker;
|
||||
};
|
||||
|
||||
export function createReportJellyfinRemoteStoppedHandler(deps: JellyfinRemoteStoppedReporterDeps) {
|
||||
@@ -226,6 +258,10 @@ export function createReportJellyfinRemoteStoppedHandler(deps: JellyfinRemoteSto
|
||||
deps.clearActivePlayback();
|
||||
return;
|
||||
}
|
||||
// Clear before any network call so progress ticks fired during the stop find nothing to
|
||||
// report, then let reports already in flight finish so none can arrive after the stop.
|
||||
deps.clearActivePlayback();
|
||||
await deps.reportTracker?.settled();
|
||||
try {
|
||||
const observedPositionSeconds = await readMpvPositionSecondsOrFallback(deps.getMpvClient());
|
||||
const positionSeconds = resolveReportablePositionSeconds(playback, observedPositionSeconds);
|
||||
@@ -244,7 +280,7 @@ export function createReportJellyfinRemoteStoppedHandler(deps: JellyfinRemoteSto
|
||||
} catch (error) {
|
||||
deps.logDebug('Failed to report Jellyfin remote final progress', error);
|
||||
}
|
||||
await session.reportStopped({
|
||||
const reported = await session.reportStopped({
|
||||
itemId: playback.itemId,
|
||||
mediaSourceId: playback.mediaSourceId,
|
||||
positionTicks,
|
||||
@@ -254,10 +290,13 @@ export function createReportJellyfinRemoteStoppedHandler(deps: JellyfinRemoteSto
|
||||
subtitleStreamIndex: playback.subtitleStreamIndex,
|
||||
eventName: 'stop',
|
||||
});
|
||||
if (reported === false) {
|
||||
deps.logWarn?.(
|
||||
`Jellyfin did not accept the playback stop report for item ${playback.itemId}; the server may keep showing it as playing.`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
deps.logDebug('Failed to report Jellyfin remote stop', error);
|
||||
} finally {
|
||||
deps.clearActivePlayback();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type JellyfinRemoteServiceOptions = {
|
||||
};
|
||||
onConnected: () => void;
|
||||
onDisconnected: () => void;
|
||||
logWarn?: (message: string, details?: unknown) => void;
|
||||
onPlay: (payload: JellyfinRemoteEventPayload) => void;
|
||||
onPlaystate: (payload: JellyfinRemoteEventPayload) => void;
|
||||
onGeneralCommand: (payload: JellyfinRemoteEventPayload) => void;
|
||||
@@ -110,6 +111,7 @@ export function createStartJellyfinRemoteSessionHandler(deps: {
|
||||
onDisconnected: () => {
|
||||
deps.logWarn('Jellyfin remote websocket disconnected; retrying.');
|
||||
},
|
||||
logWarn: (message, details) => deps.logWarn(message, details),
|
||||
onPlay: (payload) => {
|
||||
void deps.handlePlay(payload).catch((error) => {
|
||||
deps.logWarn('Failed handling Jellyfin remote Play event', error);
|
||||
|
||||
Reference in New Issue
Block a user