Skip to content

WordCensor: support Subtitle Edit Batch convert - #333

Merged
niksedk merged 1 commit into
mainfrom
claude/word-censor-batch
Oct 14, 2026
Merged

niksedk merged 1 commit into
mainfrom
claude/word-censor-batch

Conversation

@niksedk

@niksedk niksedk commented Oct 14, 2026

Copy link
Copy Markdown
Member

Adds Subtitle Edit Batch convert support (contract: SubtitleEdit/subtitleedit#16036, docs/plugin.md "Batch convert") to Word censor.

What it does

  • plugin.json: "batch": true.
  • batch request (headless, via PluginBootstrap.Run batch handler): loads the saved settings (mode, replacement text, red highlight) and censors every offensive word on all lines, the same as clicking Apply with every line checked (the window's default). No changes returns ok without a subtitle. Settings are not returned.
  • configure request: the window opens in a settings-only state. The selection buttons and change list are hidden, a short "Batch convert settings" panel is shown, and the button reads OK and is always enabled. OK returns ok with settings + settingsVersion and no subtitle. Cancel returns cancelled.
  • The settings load/save code moved from MainWindow into CensorSettings so the headless batch path can use it without touching Avalonia. The settings JSON is unchanged.

Decision: random modes in batch

Grawlix characters and random alternative words are random by design. The user chose these modes, so batch keeps them. To keep the run deterministic from saved settings, batch seeds the engine's Random from a stable FNV-1a hash of the file's text: converting the same file with the same settings gives the same output, and each file still gets its own picks. A normal run is unchanged and still uses an unseeded Random.

Compatibility

SE 5.3 ignores "batch" and only sends run. The run path works exactly as before.

Tests

  • New se5/WordCensor.Tests project (modelled on FixEncodingErrors.Tests) with BatchModeTests (6 tests: grawlix on all lines, nothing to change, saved replacement + red, reproducible grawlix/alternative, settings round-trip). word-censor.yml now runs it in a test job before build, and its path filters include the test project.
  • Ran the built dll end-to-end on batch request files: exit 0, censored SubRip returned, the same output on repeated runs, and ok with no subtitle for a clean file.
  • Not tested: the configure window was not opened manually.

🤖 Generated with Claude Code

- plugin.json "batch": true
- batch request: censor every line with the saved mode/replacement/red
  highlight, no UI; random picks seeded from the file text (reproducible)
- configure request: settings-only window, settings returned without subtitle
- new WordCensor.Tests project, run by word-censor.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@niksedk
niksedk merged commit 62b8edf into main Oct 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant