Skip to content

A feature-rich command-line audio/video downloader

[utils] `parse_duration`: Return `int` when appropriate (#13899)

doe1080e584a65f2a0f
diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py
index edaf7a665f..ede0bc93a8 100644
--- a/yt_dlp/utils/_utils.py
+++ b/yt_dlp/utils/_utils.py
@@ -2145,9 +2145,11 @@ def parse_duration(s):
if ms:
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)))
+ return int(total) if total.is_integer() else total
+
def _change_extension(prepend, filename, ext, expected_real_ext=None, *, _allowed_exts=()):
name, real_ext = os.path.splitext(filename)