Fix: Handle OCR error of "20h."

This commit is contained in:
LmeSzinc 2023-09-20 12:35:54 +08:00
parent 5e48c1bd74
commit 07ef351ed7

View File

@ -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`