mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-02 16:32:51 +01:00
Improve parse_chapters comments
This commit is contained in:
parent
e42e25619f
commit
317ba03fdf
|
@ -322,9 +322,10 @@ def validate_outtmpl(tmpl, msg):
|
||||||
|
|
||||||
def parse_chapters(name, value):
|
def parse_chapters(name, value):
|
||||||
def parse_timestamp(x):
|
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(')', '')
|
x = x.replace('(', '').replace(')', '')
|
||||||
|
|
||||||
|
# FIXME: This should be smarter, e.g. 'inf-1day'?
|
||||||
if x in ('inf', 'infinite'):
|
if x in ('inf', 'infinite'):
|
||||||
return float('inf')
|
return float('inf')
|
||||||
|
|
||||||
|
@ -337,7 +338,7 @@ def parse_timestamp(x):
|
||||||
for regex in value or []:
|
for regex in value or []:
|
||||||
if regex.startswith('*'):
|
if regex.startswith('*'):
|
||||||
for range_ in map(str.strip, regex[1:].split(',')):
|
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_)
|
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'))
|
dur = mobj and (parse_timestamp(mobj.group(1) or '0'), parse_timestamp(mobj.group(2) or 'inf'))
|
||||||
if None in (dur or [None]):
|
if None in (dur or [None]):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user