Merge pull request #116 from esha71/master

Fixed timestamp formatting in WebVTTFormatter
This commit is contained in:
jdepoix 2021-11-08 11:00:31 +01:00 committed by GitHub
commit f30e344f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions

View File

@ -95,13 +95,10 @@ class WebVTTFormatter(Formatter):
'00:00:06.930'
"""
time = float(time)
hours, mins, secs = (
int(time) // 3600,
int(time) // 60,
int(time) % 60,
)
hours, remainder = divmod(time, 3600)
mins, secs = divmod(remainder, 60)
ms = int(round((time - int(time))*1000, 2))
return "{:02d}:{:02d}:{:02d}.{:03d}".format(hours, mins, secs, ms)
return "{:02.0f}:{:02.0f}:{:02.0f}.{:03d}".format(hours, mins, secs, ms)
def format_transcript(self, transcript, **kwargs):
"""A basic implementation of WEBVTT formatting.