aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/webvtt.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-10-19 22:58:14 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-10-19 22:58:25 +0530
commitaa7785f860be0bae7135ee32fe0ef4f0ab00bbc1 (patch)
tree1c30ab046f81222cabb000b8ac9f8bf098e687b1 /yt_dlp/webvtt.py
parent9fab498fbf38dca24ef215d4789b13dd24d7952d (diff)
downloadhypervideo-pre-aa7785f860be0bae7135ee32fe0ef4f0ab00bbc1.tar.lz
hypervideo-pre-aa7785f860be0bae7135ee32fe0ef4f0ab00bbc1.tar.xz
hypervideo-pre-aa7785f860be0bae7135ee32fe0ef4f0ab00bbc1.zip
[utils] Standardize timestamp formatting code
Closes #1285
Diffstat (limited to 'yt_dlp/webvtt.py')
-rw-r--r--yt_dlp/webvtt.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/yt_dlp/webvtt.py b/yt_dlp/webvtt.py
index cd936e7e5..962aa57ad 100644
--- a/yt_dlp/webvtt.py
+++ b/yt_dlp/webvtt.py
@@ -13,7 +13,7 @@ in RFC 8216 ยง3.5 <https://tools.ietf.org/html/rfc8216#section-3.5>.
import re
import io
-from .utils import int_or_none
+from .utils import int_or_none, timetuple_from_msec
from .compat import (
compat_str as str,
compat_Pattern,
@@ -124,11 +124,7 @@ def _format_ts(ts):
Convert an MPEG PES timestamp into a WebVTT timestamp.
This will lose sub-millisecond precision.
"""
- 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)
+ return '%02u:%02u:%02u.%03u' % timetuple_from_msec(int((ts + 45) // 90))
class Block(object):