mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-07-02 16:28:52 +00:00
[utils] parse_duration: Return int when appropriate (#13899)
Authored by: doe1080
This commit is contained in:
parent
c84b2c6736
commit
e584a65f2a
@ -2145,9 +2145,11 @@ def parse_duration(s):
|
|||||||
|
|
||||||
if ms:
|
if ms:
|
||||||
ms = ms.replace(':', '.')
|
ms = ms.replace(':', '.')
|
||||||
return sum(float(part or 0) * mult for part, mult in (
|
total = sum(float(part or 0) * mult for part, mult in (
|
||||||
(days, 86400), (hours, 3600), (mins, 60), (secs, 1), (ms, 1)))
|
(days, 86400), (hours, 3600), (mins, 60), (secs, 1), (ms, 1)))
|
||||||
|
|
||||||
|
return int(total) if total.is_integer() else total
|
||||||
|
|
||||||
|
|
||||||
def _change_extension(prepend, filename, ext, expected_real_ext=None, *, _allowed_exts=()):
|
def _change_extension(prepend, filename, ext, expected_real_ext=None, *, _allowed_exts=()):
|
||||||
name, real_ext = os.path.splitext(filename)
|
name, real_ext = os.path.splitext(filename)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user