fix: Regex bug when parsing time.
This commit is contained in:
parent
892fa502e6
commit
c9b170d865
@ -279,7 +279,7 @@ help = <h3>Commands</h3>
|
||||
<b>Control</b>
|
||||
<ul>
|
||||
<li> <b>!<u>w</u>eb</b> - get the URL of the web interface, if enabled. </li>
|
||||
<li> <b>!play </b> (or <b>!p</b>) [{num}] - resume from pausing / start to play (the num-th song is num if given) </li>
|
||||
<li> <b>!play </b> (or <b>!p</b>) [{num}] [{start_from}] - resume from pausing / start to play (the num-th song is num if given) </li>
|
||||
<li> <b>!<u>pa</u>use </b> - pause </li>
|
||||
<li> <b>!<u>st</u>op </b> - stop playing </li>
|
||||
<li> <b>!<u>sk</u>ip </b> - jump to the next song </li>
|
||||
|
4
util.py
4
util.py
@ -366,14 +366,14 @@ def get_media_duration(path):
|
||||
|
||||
|
||||
def parse_time(human):
|
||||
match = re.search("(?:(\d\d):)?(?:(\d\d):)?(\d\d(?:\.\d*)?)", human, flags=re.IGNORECASE)
|
||||
match = re.search("(?:(\d\d):)?(?:(\d\d):)?(\d+(?:\.\d*)?)", human, flags=re.IGNORECASE)
|
||||
if match:
|
||||
if match[1] is None and match[2] is None:
|
||||
return float(match[3])
|
||||
elif match[2] is None:
|
||||
return float(match[3]) + 60 * int(match[1])
|
||||
else:
|
||||
return float(match[3]) + 60 * int(match[2]) + 3600 * int(match[2])
|
||||
return float(match[3]) + 60 * int(match[2]) + 3600 * int(match[1])
|
||||
else:
|
||||
raise ValueError("Invalid time string given.")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user