Skip to content

fix: deduplicate secondary subtitle lines - #173

Merged
tatsumoto-ren merged 3 commits into
Ajatt-Tools:masterfrom
kuator:fix/deduplicate-secondary-lines
Aug 9, 2026
Merged

fix: deduplicate secondary subtitle lines#173
tatsumoto-ren merged 3 commits into
Ajatt-Tools:masterfrom
kuator:fix/deduplicate-secondary-lines

Conversation

@kuator

@kuator kuator commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

There's a problem when text get duplicated between two subtitles. Then I have to remove the duplicated text manually which is a pain. The other thing that annoys me is if I have Japanese cue with, let's say, 3 corresponding english cues, I have to manually select these overlapping english cues. This mr simply grabs all the corresponding english cues that fall into the range of the japanese cue.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses duplicated text when collecting/combining secondary subtitles (e.g., when one subtitle expands and repeats the previous line), reducing the need for manual cleanup during export.

Changes:

  • Add an optional deduplicate_lines mode to subtitles.sub_list to remove duplicated secondary lines while concatenating.
  • Enable line deduplication for secondary subtitle buffers in subtitles/observer.lua.
  • Add basic regression tests for subtitle list concatenation behavior in tests/run.lua.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
mpvacious/subtitles/sub_list.lua Adds optional line-deduplication behavior when concatenating subtitle text.
mpvacious/subtitles/observer.lua Enables the new deduplication mode for secondary subtitle collections used during export.
tests/run.lua Adds subtitle list tests covering duplicated-line behavior for secondary subtitles.

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mpvacious/subtitles/sub_list.lua Outdated
Comment thread tests/run.lua Outdated
@kuator
kuator force-pushed the fix/deduplicate-secondary-lines branch 2 times, most recently from ae4c9a8 to bc6748f Compare August 6, 2026 19:17
Comment thread mpvacious/anki/note_exporter.lua Outdated
Comment thread mpvacious/subtitles/observer.lua
Comment thread tests/run.lua Outdated
Comment thread tests/run.lua Outdated
Comment thread mpvacious/anki/note_exporter.lua Outdated
@kuator
kuator force-pushed the fix/deduplicate-secondary-lines branch from bc6748f to 664c573 Compare August 7, 2026 17:59
@kuator

kuator commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

image And after I press ctrl+m, it captures the second cue as well
image

extract make_speech_collector

add function list_equal()

add speech collector

simplify tests

update comments

add tests
@tatsumoto-ren
tatsumoto-ren force-pushed the fix/deduplicate-secondary-lines branch from 4b95adb to c9d9a44 Compare August 9, 2026 13:19
@tatsumoto-ren
tatsumoto-ren merged commit 0bf99eb into Ajatt-Tools:master Aug 9, 2026
@tatsumoto-ren

tatsumoto-ren commented Aug 9, 2026

Copy link
Copy Markdown
Member

I did everything I could to refactor the code and make it understandable. But commit 4b95adb is left out for now. I'm not sure if we need something like that. Better discuss it separately.

@kuator

kuator commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

I can extract it in a separate mr where others can weigh in on whether this functionality is needed in the first place

@tatsumoto-ren

Copy link
Copy Markdown
Member

If a PR is clean, I can merge it right away. But when a PR is not clean enough to meet the repo's code quality bar, it takes a lot of work to refactor it before merging.

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.

3 participants