mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
feat(subtitles): add regex subtitle filters with built-in presets (#318)
- Add `subtitleFilter` config with four presets: parentheses, brackets, speaker prefix and music symbols. Custom regex rules run after the presets. - Filter primary text where it enters the app (live `sub-text` and parsed cues), so the overlay, sidebar, mining and stats all get the same filtered text. - Changes hot-reload: the current line is read again and the active track is parsed again, using the filter config as the prefetch parse key. - Add a custom rule editor in Settings under Behavior → Subtitle Filters that checks patterns as you type. - Update the config example, the configuration docs and the architecture domains doc, and add a changelog fragment.
This commit is contained in:
1 parent
848a6c4021
commit
fa3051f9cb
28 files changed
+740
-11
No files matched your search
@@ -52,7 +52,7 @@ SubMiner watches the config file while running. When it changes, live settings a
|
||||
|
||||
These apply live:
|
||||
|
||||
- `subtitleStyle`, `subtitleSidebar`, `subtitleSelection`, `keybindings`, `shortcuts`
|
||||
- `subtitleStyle`, `subtitleSidebar`, `subtitleSelection`, `subtitleFilter`, `keybindings`, `shortcuts`
|
||||
- `logging.level`, `logging.rotation`, `logging.files`
|
||||
- `secondarySub.defaultMode`, `youtube.primarySubLanguages`, `youtube.subtitleSource`
|
||||
- `mpv.aniskipEnabled`, `mpv.aniskipButtonKey`, `stats.toggleKey`, `stats.markWatchedKey`
|
||||
@@ -221,6 +221,29 @@ Sidebar custom properties: `--subtitle-sidebar-max-width` (`420px`), `--subtitle
|
||||
|
||||
If `embedded` layout places the video oddly on your system, switch back to `overlay`.
|
||||
|
||||
### Subtitle filters {#subtitle-filters}
|
||||
|
||||
Removes unwanted text from primary subtitles, such as speaker names, readings and sound descriptions. Filtering happens as the line arrives, so the overlay, sidebar, mined sentences and stats all see the filtered text. A line left with no words is hidden. In the settings window, find it under **Behavior → Subtitle Filters**.
|
||||
|
||||
| Key | Default | What it does |
|
||||
| -------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `subtitleFilter.presets.parentheses` | `false` | Remove `(…)` and `(…)` anywhere in a line. A line wrapped entirely in parentheses (inner thoughts) is kept |
|
||||
| `subtitleFilter.presets.brackets` | `false` | Remove `[…]`, `[…]`, `【…】` and `〔…〕`, such as sound effects |
|
||||
| `subtitleFilter.presets.speakerPrefix` | `false` | Remove a short name before a colon at the start of a line, as in `山田:` |
|
||||
| `subtitleFilter.presets.musicSymbols` | `false` | Remove `♪`, `♫` and `♬` |
|
||||
| `subtitleFilter.customRules` | `[]` | Your own regex rules, applied in order after the presets |
|
||||
|
||||
Each custom rule is `{ "name", "pattern", "replacement", "enabled" }`. Patterns are JavaScript regular expressions compiled with the `gmu` flags, so `^` and `$` match each line. An empty `replacement` removes the match.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"subtitleFilter": {
|
||||
"presets": { "parentheses": true },
|
||||
"customRules": [{ "name": "Join lines", "pattern": "\\n", "replacement": "", "enabled": true }],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Subtitle position
|
||||
|
||||
You can also drag subtitles with `Right-click + drag` while watching.
|
||||
|
||||
@@ -854,6 +854,22 @@
|
||||
} // CSS declaration object applied to the subtitle sidebar. Includes color, background-color, and all font properties.
|
||||
}, // Parsed-subtitle sidebar cue list styling, behavior, and toggle key.
|
||||
|
||||
// ==========================================
|
||||
// Subtitle Filters
|
||||
// Remove unwanted text from primary subtitles, such as speaker names, readings and sound descriptions.
|
||||
// Applies to the overlay, sidebar, mined sentences and stats.
|
||||
// Hot-reload: filter changes apply to the current subtitle file immediately.
|
||||
// ==========================================
|
||||
"subtitleFilter": {
|
||||
"presets": {
|
||||
"parentheses": false, // Remove text in () and (), such as speaker names, readings and notes. A line wrapped entirely in parentheses, usually inner thoughts, is kept. Values: true | false
|
||||
"brackets": false, // Remove text in [], [], 【】 and 〔〕, such as sound effects and music cues. Values: true | false
|
||||
"speakerPrefix": false, // Remove a short name followed by a colon at the start of a line, as in 山田:元気? Values: true | false
|
||||
"musicSymbols": false // Remove ♪, ♫ and ♬. A line left with only symbols such as ~ is removed. Values: true | false
|
||||
}, // Built-in filters. Each removes its matches and is off by default.
|
||||
"customRules": [] // Your own regex rules, applied in order after the presets. Each rule is { name, pattern, replacement, enabled }; patterns use the gmu flags, so ^ and $ match per line. Leave replacement empty to remove the match.
|
||||
}, // Remove unwanted text from primary subtitles, such as speaker names, readings and sound descriptions.
|
||||
|
||||
// ==========================================
|
||||
// Shared AI Provider
|
||||
// Canonical OpenAI-compatible provider transport settings shared by Anki and YouTube subtitle fixing.
|
||||
|
||||
Reference in new issue
Block a user