From 3dc46ff6977ef72a01496720209702cfed5b3191 Mon Sep 17 00:00:00 2001 From: "Du, Song" Date: Sat, 5 Jun 2021 00:28:17 -0400 Subject: [PATCH] [bilibili] fix srt conversion when timestamp is long float --- youtube_dl/extractor/bilibili.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/bilibili.py b/youtube_dl/extractor/bilibili.py index 6f88ce678..a4c59f985 100644 --- a/youtube_dl/extractor/bilibili.py +++ b/youtube_dl/extractor/bilibili.py @@ -113,12 +113,10 @@ class BiliBiliIE(InfoExtractor): _BILIBILI_KEY = 'aHRmhWMLkdeMuILqORnYZocwMBpMEOdt' def convert_timestamp_format(self, cc_timestamp): - s, mm = int(cc_timestamp), 0 - if "." in str(cc_timestamp): - s, mm = map(int, str(cc_timestamp).split(".")) - m, s = divmod(s, 60) + ss, mm = "{:.3f}".format(float(cc_timestamp)).split(".") + m, s = divmod(int(ss), 60) h, m = divmod(m, 60) - return "%02d:%02d:%02d,%03d" % (h, m, s, mm) + return "%02d:%02d:%02d,%s" % (h, m, s, mm) def _report_error(self, result): if 'message' in result: