]> jfr.im git - yt-dlp.git/commitdiff
[webtt] Fix timestamps
authorpukkandan <redacted>
Sun, 11 Jul 2021 23:35:32 +0000 (05:05 +0530)
committerpukkandan <redacted>
Sun, 11 Jul 2021 23:50:12 +0000 (05:20 +0530)
Closes #474

yt_dlp/webvtt.py

index a184ee369933343f49d68e4917f681f81082498e..ef55e6459ad2ae0ed9045495b3bdbf9f038fef33 100644 (file)
@@ -120,12 +120,11 @@ def _format_ts(ts):
     Convert an MPEG PES timestamp into a WebVTT timestamp.
     This will lose sub-millisecond precision.
     """
-
-    ts = int((ts + 45) // 90)
-    ms , ts = divmod(ts, 1000)  # noqa: W504,E221,E222,E203
-    s  , ts = divmod(ts, 60)    # noqa: W504,E221,E222,E203
-    min, h  = divmod(ts, 60)    # noqa: W504,E221,E222
-    return '%02u:%02u:%02u.%03u' % (h, min, s, ms)
+    msec = int((ts + 45) // 90)
+    secs, msec = divmod(msec, 1000)
+    mins, secs = divmod(secs, 60)
+    hrs, mins = divmod(mins, 60)
+    return '%02u:%02u:%02u.%03u' % (hrs, mins, secs, msec)
 
 
 class Block(object):