Improve parse_chapters comments

This commit is contained in:
Elyse 2023-03-09 18:34:45 -06:00
parent e42e25619f
commit 317ba03fdf

View file

@ -322,9 +322,10 @@ def validate_outtmpl(tmpl, msg):
def parse_chapters(name, value):
def parse_timestamp(x):
# FIXME: This should be smarter, e.g. 'inf-1day'?
# FIXME: Maybe there's a better way to remove parenthesis
x = x.replace('(', '').replace(')', '')
# FIXME: This should be smarter, e.g. 'inf-1day'?
if x in ('inf', 'infinite'):
return float('inf')
@ -337,7 +338,7 @@ def parse_timestamp(x):
for regex in value or []:
if regex.startswith('*'):
for range_ in map(str.strip, regex[1:].split(',')):
# FIXME: This is really sensible
# FIXME: This should match correctly '(now-1hour)-(now-20minutes)'
mobj = range_ != '-' and re.fullmatch(r'(.+)?\s*-\s*(.+)?', range_)
dur = mobj and (parse_timestamp(mobj.group(1) or '0'), parse_timestamp(mobj.group(2) or 'inf'))
if None in (dur or [None]):