From 1afc2d510526bf149d581d3251cb9a91618c9bda Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 19 Aug 2026 19:10:31 +0200 Subject: [PATCH] Fix dropped PGS acquisition frames when there is no compositions frame --- subtle_gui/formats/pgssubs.py | 4 +++- subtle_gui/ocr/tesseract.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/subtle_gui/formats/pgssubs.py b/subtle_gui/formats/pgssubs.py index a8d9cf1..8923d67 100644 --- a/subtle_gui/formats/pgssubs.py +++ b/subtle_gui/formats/pgssubs.py @@ -122,8 +122,10 @@ def _readData(self, path: Path) -> None: frames = [] for ds in data: state = ds.pcs.compState - if state == COMP_EPOCH: + if state == COMP_EPOCH or (state == COMP_ACQ and not frame): # Start of a new subtitles frame. + # We assume that acquisition frames after closed frames are also valid subtitles. + # These sometimes occur, and I'm not really sure why. frame = PGSFrame(len(frames), ds) frames.append(frame) elif ds.isClearFrame() and frame: diff --git a/subtle_gui/ocr/tesseract.py b/subtle_gui/ocr/tesseract.py index 17bb20f..df48082 100644 --- a/subtle_gui/ocr/tesseract.py +++ b/subtle_gui/ocr/tesseract.py @@ -51,7 +51,7 @@ RX_REPLACE = { "all": [ - (re.compile(r"^(-\s)[\w]", re.UNICODE), "-"), + # (re.compile(r"^(-\s)[\w]", re.UNICODE), "-"), (re.compile(r"^(\.{2})[\s\w]", re.UNICODE), "..."), (re.compile(r"^(\.{3}\s)\w", re.UNICODE), "..."), # Wrong capitalisation in the middle of words