def parse_duration(text): """Parse durations like '1h30m', '45s', '2h5s' or '90m' into total seconds.""" import re total = 0 for value, unit in re.findall(r"(\d+)([hm])", text): total += int(value) * {"h": 3600, "m": 60}[unit] return total