From c3e672efdb9f3aae3850d352dca59c5bb1875a36 Mon Sep 17 00:00:00 2001 From: sudacode Date: Wed, 4 Nov 2026 22:02:05 -0800 Subject: [PATCH] refactor(plugins): remove auto-jimaku example plugin and fix docs - Remove the auto-jimaku example, now covered by the built-in Jimaku auto-open - Drop its plugins docs section and changelog bullet - List the keyboard-only `C` key in Keyboard shortcuts - Point the configuration reference to Controller support for button defaults --- assets/plugins/auto-jimaku/main.js | 51 ------------------- assets/plugins/auto-jimaku/plugin.json | 6 --- changes/docs-keyboard-character-navigation.md | 4 ++ changes/plugin-system.md | 1 - docs-site/configuration.md | 2 +- docs-site/plugins.md | 11 ---- docs-site/shortcuts.md | 1 + 7 files changed, 6 insertions(+), 70 deletions(-) delete mode 100644 assets/plugins/auto-jimaku/main.js delete mode 100644 assets/plugins/auto-jimaku/plugin.json create mode 100644 changes/docs-keyboard-character-navigation.md diff --git a/assets/plugins/auto-jimaku/main.js b/assets/plugins/auto-jimaku/main.js deleted file mode 100644 index 1744e621..00000000 --- a/assets/plugins/auto-jimaku/main.js +++ /dev/null @@ -1,51 +0,0 @@ -// Opens the Jimaku subtitle search when a file starts without a Japanese subtitle track. -// It waits a few seconds after the file loads so external subtitles mpv or SubMiner add count. - -const DEFAULT_SETTINGS = { - // Built-in action to run, e.g. `openTsukihime` or `openSubtitleSelection`. - action: 'openJimaku', - // Track `lang` codes that count as Japanese. Track titles with "Japanese" or 日本語 count too. - languages: ['ja', 'jp', 'jpn'], - delayMs: 3_000, - // Also check http(s) streams; Jimaku can only search by name, which streams rarely have. - streams: false, -}; - -const JAPANESE_TITLE = /japanese|日本語/i; - -function activate(ctx) { - const settings = { ...DEFAULT_SETTINGS, ...ctx.settings }; - const languages = new Set(settings.languages.map((lang) => lang.toLowerCase())); - let cancelCheck = null; - let playbackId = null; - - function hasJapaneseSubtitle(trackList) { - return trackList.some( - (track) => - track?.type === 'sub' && - (languages.has(String(track.lang ?? '').toLowerCase()) || - JAPANESE_TITLE.test(String(track.title ?? ''))), - ); - } - - async function check(media) { - cancelCheck = null; - const trackList = await ctx.mpv.getProperty('track-list'); - if (ctx.media.current()?.playbackId !== media.playbackId || !Array.isArray(trackList)) return; - if (hasJapaneseSubtitle(trackList)) return; - ctx.log.info(`No Japanese subtitles for ${media.path}; running ${settings.action}.`); - await ctx.actions.run(settings.action); - } - - ctx.media.on('change', (media) => { - if (media?.playbackId === playbackId) return; - playbackId = media?.playbackId ?? null; - cancelCheck?.(); - cancelCheck = null; - if (!media) return; - if (!settings.streams && /^[a-z]+:\/\//i.test(media.path)) return; - cancelCheck = ctx.after(settings.delayMs, () => check(media)); - }); -} - -module.exports = { activate }; diff --git a/assets/plugins/auto-jimaku/plugin.json b/assets/plugins/auto-jimaku/plugin.json deleted file mode 100644 index 2b720859..00000000 --- a/assets/plugins/auto-jimaku/plugin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Auto Jimaku", - "version": "1.0.0", - "apiVersion": 1, - "main": "main.js" -} diff --git a/changes/docs-keyboard-character-navigation.md b/changes/docs-keyboard-character-navigation.md new file mode 100644 index 00000000..0bc1f77f --- /dev/null +++ b/changes/docs-keyboard-character-navigation.md @@ -0,0 +1,4 @@ +type: docs +area: overlay + +- Listed the keyboard-only `C` key in Keyboard shortcuts, and pointed the configuration reference to Controller support for default button actions. diff --git a/changes/plugin-system.md b/changes/plugin-system.md index 43e860ef..53454dfc 100644 --- a/changes/plugin-system.md +++ b/changes/plugin-system.md @@ -5,6 +5,5 @@ area: plugins - Added an example `ai-explain` plugin that sends the current line and its neighbors to `codex exec` and shows a translation or grammar explanation. - Added an example `anki-sync` plugin that syncs Anki to AnkiWeb after you mine cards, once mining goes quiet or playback ends. - Added an example `episode-tags` plugin that tags mined cards with the show and episode, such as `show::Frieren::S01E07`. -- Added an example `auto-jimaku` plugin that opens the Jimaku search when a file starts without a Japanese subtitle track. - Added a versioned plugin API with standalone authoring types, cached playback snapshots, lifecycle cancellation and cleanup, and awaitable mpv commands. Async activation is bounded and actions wait only for their own plugin. Shutdown skips pending loads, runs each deactivation once, and blocks calls from disposed plugins. - Mining events preserve original and kept note ids with the media and subtitle captured when mining starts, so delayed enrichment and merges into older notes keep the source episode. Stats-dashboard cards do not trigger plugin events. Plugin subtitle lookups and mining provenance account for subtitle delay and return timing on the subtitle file's timeline. diff --git a/docs-site/configuration.md b/docs-site/configuration.md index bd0693c9..a8119e65 100644 --- a/docs-site/configuration.md +++ b/docs-site/configuration.md @@ -314,7 +314,7 @@ Adds a modal for choosing mpv's primary and secondary subtitle tracks. Open it w ### Controller support -Gamepad input for the overlay, through the browser Gamepad API. Most actions only work while keyboard-only mode is on; the toggle for that mode, the secondary subtitle hold (`controller.bindings.holdSecondarySub`), pause (`toggleMpvPause`) and the subtitle line actions (`previousSubtitle`, `nextSubtitle`, `replaySubtitle`, `playNextSubtitle`) work either way. Use the `Alt+C` modal to pick a controller and learn bindings, and `Alt+Shift+C` to see raw button and axis values. Default button actions are on [Keyboard shortcuts](/shortcuts). +Gamepad input for the overlay, through the browser Gamepad API. Most actions only work while keyboard-only mode is on; the toggle for that mode, the secondary subtitle hold (`controller.bindings.holdSecondarySub`), pause (`toggleMpvPause`) and the subtitle line actions (`previousSubtitle`, `nextSubtitle`, `replaySubtitle`, `playNextSubtitle`) work either way. Use the `Alt+C` modal to pick a controller and learn bindings, and `Alt+Shift+C` to see raw button and axis values. Default button actions are in [Controller support](/usage#controller-support). | Key | Default | What it does | | ---------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | diff --git a/docs-site/plugins.md b/docs-site/plugins.md index a0e6a6c9..f9bd7ac9 100644 --- a/docs-site/plugins.md +++ b/docs-site/plugins.md @@ -83,17 +83,6 @@ Anki must be running and logged in to AnkiWeb. Cards mined from the stats dashbo Templates can use `{show}`, `{season}`, `{episode}`, and `{ep}` (`S01E07`, or `E07` when there is no season). When a placeholder has no value, the tag stops before that `::` level, so a movie gets `show::`. The parsing is a guess from the name: a title ending in a number, like `Mob Psycho 100`, reads that number as the episode. -## Example: open Jimaku when a file has no Japanese subtitles - -[`assets/plugins/auto-jimaku`](https://github.com/ksyasuda/SubMiner/tree/main/assets/plugins/auto-jimaku) opens the Jimaku search a few seconds after a file starts if none of its subtitle tracks is Japanese. A track counts as Japanese when its language code is in `languages`, or its title contains "Japanese" or 日本語. - -| Setting | Default | What it does | -| ----------- | --------------------- | --------------------------------------------------------------- | -| `action` | `"openJimaku"` | Built-in action to run, e.g. `openTsukihime` | -| `languages` | `["ja", "jp", "jpn"]` | Track language codes that count as Japanese | -| `delayMs` | `3000` | Wait this long after the file starts, so external subs load | -| `streams` | `false` | Also check `http(s)` streams, which Jimaku usually can't search | - ## Write a plugin A plugin folder needs a `plugin.json`: diff --git a/docs-site/shortcuts.md b/docs-site/shortcuts.md index 44cb6f33..207aae13 100644 --- a/docs-site/shortcuts.md +++ b/docs-site/shortcuts.md @@ -62,6 +62,7 @@ Built into the overlay, not configurable: | Input | Action | | ------------------------- | -------------------------------------------------- | | `V` | Cycle primary subtitle bar: hidden, visible, hover | +| `C` (keyboard-only mode) | Move by word or by character | | Right-click | Pause or resume (outside the subtitle area) | | Right-click + drag | Move the subtitles | | Drop files on the overlay | Replace the mpv playlist |