mirror of
https://github.com/ytdl-org/ytdl-nightly.git
synced 2024-12-23 13:32:08 +01:00
[nrk] Remove TTML to srt conversion codes
A common routine is implemented in utils.py and can be used via --convert-subtitles.
This commit is contained in:
parent
7dff03636a
commit
1c7e2e64f6
@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
@ -200,20 +199,10 @@ class NRKTVIE(InfoExtractor):
|
|||||||
url = "%s%s" % (baseurl, subtitlesurl)
|
url = "%s%s" % (baseurl, subtitlesurl)
|
||||||
self._debug_print('%s: Subtitle url: %s' % (video_id, url))
|
self._debug_print('%s: Subtitle url: %s' % (video_id, url))
|
||||||
captions = self._download_xml(
|
captions = self._download_xml(
|
||||||
url, video_id, 'Downloading subtitles',
|
url, video_id, 'Downloading subtitles')
|
||||||
transform_source=lambda s: s.replace(r'<br />', '\r\n'))
|
|
||||||
lang = captions.get('lang', 'no')
|
lang = captions.get('lang', 'no')
|
||||||
ps = captions.findall('./{0}body/{0}div/{0}p'.format('{http://www.w3.org/ns/ttml}'))
|
|
||||||
srt = ''
|
|
||||||
for pos, p in enumerate(ps):
|
|
||||||
begin = parse_duration(p.get('begin'))
|
|
||||||
duration = parse_duration(p.get('dur'))
|
|
||||||
starttime = self._subtitles_timecode(begin)
|
|
||||||
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)
|
|
||||||
return {lang: [
|
return {lang: [
|
||||||
{'ext': 'ttml', 'url': url},
|
{'ext': 'ttml', 'url': url},
|
||||||
{'ext': 'srt', 'data': srt},
|
|
||||||
]}
|
]}
|
||||||
|
|
||||||
def _extract_f4m(self, manifest_url, video_id):
|
def _extract_f4m(self, manifest_url, video_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user