From 07ef351ed78baa8e8372a81fd894e38cc657b038 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:35:54 +0800 Subject: [PATCH] Fix: Handle OCR error of "20h." --- module/ocr/ocr.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/ocr/ocr.py b/module/ocr/ocr.py index 433381433..81506bfa7 100644 --- a/module/ocr/ocr.py +++ b/module/ocr/ocr.py @@ -389,6 +389,11 @@ class Duration(Ocr): }[lang] return re.compile(regex_str) + def after_process(self, result): + result = super().after_process(result) + result = result.strip('.,。,') + return result + def format_result(self, result: str) -> timedelta: """ Do OCR on a duration, such as `18d 2h 13m 30s`, `2h`, `13m 30s`, `9s`