From 2e624bed40eb97b46faa98094a0b74d3ececd93d Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 17 Sep 2026 16:31:25 +0200 Subject: [PATCH] [fix] utils.parse_duration_string - the last three of [00, HH, MM, SS] (#6743) Signed-off-by: Markus Heiser --- searx/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/searx/utils.py b/searx/utils.py index 8a30de909..de795ab8d 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -794,9 +794,10 @@ def js_obj_str_to_json_str(js_obj_str: str) -> str: def parse_duration_string(duration_str: str) -> timedelta | None: - """Parse a time string in format MM:SS or HH:MM:SS and convert it to a `timedelta` object. + """Parse a time string in format MM:SS or HH:MM:SS and convert it to a + :obj:`datetime.timedelta` object. - Returns None if the provided string doesn't match any of the formats. + Returns ``None`` if the provided string doesn't match any of the formats. """ duration_str = duration_str.strip() @@ -805,7 +806,7 @@ def parse_duration_string(duration_str: str) -> timedelta | None: try: # prepending ["00"] here inits hours to 0 if they are not provided - time_parts = (["00"] + duration_str.split(":"))[:3] + time_parts = (["00"] + duration_str.split(":"))[-3:] hours, minutes, seconds = map(int, time_parts) return timedelta(hours=hours, minutes=minutes, seconds=seconds)