mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 21:56:53 +01:00
[nrk] Use generic subtitles timecode formatter
This commit is contained in:
parent
3f4327520c
commit
545315a985
@ -149,9 +149,6 @@ class NRKTVIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def _seconds2str(self, s):
|
|
||||||
return '%02d:%02d:%02d.%03d' % (s / 3600, (s % 3600) / 60, s % 60, (s % 1) * 1000)
|
|
||||||
|
|
||||||
def _debug_print(self, txt):
|
def _debug_print(self, txt):
|
||||||
if self._downloader.params.get('verbose', False):
|
if self._downloader.params.get('verbose', False):
|
||||||
self.to_screen('[debug] %s' % txt)
|
self.to_screen('[debug] %s' % txt)
|
||||||
@ -168,8 +165,8 @@ def _get_subtitles(self, subtitlesurl, video_id, baseurl):
|
|||||||
for pos, p in enumerate(ps):
|
for pos, p in enumerate(ps):
|
||||||
begin = parse_duration(p.get('begin'))
|
begin = parse_duration(p.get('begin'))
|
||||||
duration = parse_duration(p.get('dur'))
|
duration = parse_duration(p.get('dur'))
|
||||||
starttime = self._seconds2str(begin)
|
starttime = self._subtitles_timecode(begin)
|
||||||
endtime = self._seconds2str(begin + duration)
|
endtime = self._subtitles_timecode(begin + duration)
|
||||||
srt += '%s\r\n%s --> %s\r\n%s\r\n\r\n' % (compat_str(pos), starttime, endtime, p.text)
|
srt += '%s\r\n%s --> %s\r\n%s\r\n\r\n' % (compat_str(pos), starttime, endtime, p.text)
|
||||||
return {lang: [
|
return {lang: [
|
||||||
{'ext': 'ttml', 'url': url},
|
{'ext': 'ttml', 'url': url},
|
||||||
|
Loading…
Reference in New Issue
Block a user