mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[utils] Improve parse_duration
Now dots are parsed. For example '87 Min.'
This commit is contained in:
parent
1e12429564
commit
9c29bc69f7
2 changed files with 3 additions and 2 deletions
|
@ -324,6 +324,7 @@ def test_parse_duration(self):
|
||||||
self.assertEqual(parse_duration('02:03:04'), 7384)
|
self.assertEqual(parse_duration('02:03:04'), 7384)
|
||||||
self.assertEqual(parse_duration('01:02:03:04'), 93784)
|
self.assertEqual(parse_duration('01:02:03:04'), 93784)
|
||||||
self.assertEqual(parse_duration('1 hour 3 minutes'), 3780)
|
self.assertEqual(parse_duration('1 hour 3 minutes'), 3780)
|
||||||
|
self.assertEqual(parse_duration('87 Min.'), 5220)
|
||||||
|
|
||||||
def test_fix_xml_ampersands(self):
|
def test_fix_xml_ampersands(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
|
@ -1309,10 +1309,10 @@ def parse_duration(s):
|
||||||
m = re.match(
|
m = re.match(
|
||||||
r'''(?ix)(?:P?T)?
|
r'''(?ix)(?:P?T)?
|
||||||
(?:
|
(?:
|
||||||
(?P<only_mins>[0-9.]+)\s*(?:mins?|minutes?)\s*|
|
(?P<only_mins>[0-9.]+)\s*(?:mins?\.?|minutes?)\s*|
|
||||||
(?P<only_hours>[0-9.]+)\s*(?:hours?)|
|
(?P<only_hours>[0-9.]+)\s*(?:hours?)|
|
||||||
|
|
||||||
\s*(?P<hours_reversed>[0-9]+)\s*(?:[:h]|hours?)\s*(?P<mins_reversed>[0-9]+)\s*(?:[:m]|mins?|minutes?)\s*|
|
\s*(?P<hours_reversed>[0-9]+)\s*(?:[:h]|hours?)\s*(?P<mins_reversed>[0-9]+)\s*(?:[:m]|mins?\.?|minutes?)\s*|
|
||||||
(?:
|
(?:
|
||||||
(?:
|
(?:
|
||||||
(?:(?P<days>[0-9]+)\s*(?:[:d]|days?)\s*)?
|
(?:(?P<days>[0-9]+)\s*(?:[:d]|days?)\s*)?
|
||||||
|
|
Loading…
Reference in a new issue