mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-28 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
@@ -1,6 +1,10 @@
|
||||
import { ResolvedConfig } from '../../types/config';
|
||||
import { ConfigOptionRegistryEntry } from './shared';
|
||||
import { SUBTITLE_GENERATION_MODELS } from '../../shared/subtitle-generation-model-catalog';
|
||||
import {
|
||||
SUBTITLE_FILTER_PRESET_IDS,
|
||||
SUBTITLE_FILTER_PRESETS,
|
||||
} from '../../shared/subtitle-text-filter';
|
||||
|
||||
export function buildSubtitleConfigOptionRegistry(
|
||||
defaultConfig: ResolvedConfig,
|
||||
@@ -340,5 +344,24 @@ export function buildSubtitleConfigOptionRegistry(
|
||||
defaultValue: defaultConfig.subtitleSidebar.hoverLineBackgroundColor,
|
||||
description: 'Background color for hovered subtitle cues.',
|
||||
},
|
||||
{
|
||||
path: 'subtitleFilter.presets',
|
||||
kind: 'object',
|
||||
defaultValue: defaultConfig.subtitleFilter.presets,
|
||||
description: 'Built-in filters. Each removes its matches and is off by default.',
|
||||
},
|
||||
...SUBTITLE_FILTER_PRESET_IDS.map((id) => ({
|
||||
path: `subtitleFilter.presets.${id}`,
|
||||
kind: 'boolean' as const,
|
||||
defaultValue: defaultConfig.subtitleFilter.presets[id],
|
||||
description: SUBTITLE_FILTER_PRESETS[id].description,
|
||||
})),
|
||||
{
|
||||
path: 'subtitleFilter.customRules',
|
||||
kind: 'array',
|
||||
defaultValue: defaultConfig.subtitleFilter.customRules,
|
||||
description:
|
||||
'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.',
|
||||
},
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user