mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 02:19:36 +02:00
[theplatform] Convert to new subtitles system
This commit is contained in:
parent
4f7cea6c53
commit
8807f1277f
@ -24,6 +24,7 @@
|
|||||||
NRKTVIE,
|
NRKTVIE,
|
||||||
RaiIE,
|
RaiIE,
|
||||||
VikiIE,
|
VikiIE,
|
||||||
|
ThePlatformIE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -385,5 +386,19 @@ def test_allsubtitles(self):
|
|||||||
self.assertEqual(md5(subtitles['en']), 'b0b781eeb45efd3f6398a925b259150b')
|
self.assertEqual(md5(subtitles['en']), 'b0b781eeb45efd3f6398a925b259150b')
|
||||||
|
|
||||||
|
|
||||||
|
class TestThePlatformSubtitles(BaseTestSubtitles):
|
||||||
|
# from http://www.3playmedia.com/services-features/tools/integrations/theplatform/
|
||||||
|
# (see http://theplatform.com/about/partners/type/subtitles-closed-captioning/)
|
||||||
|
url = 'theplatform:JFUjUE1_ehvq'
|
||||||
|
IE = ThePlatformIE
|
||||||
|
|
||||||
|
def test_allsubtitles(self):
|
||||||
|
self.DL.params['writesubtitles'] = True
|
||||||
|
self.DL.params['allsubtitles'] = True
|
||||||
|
subtitles = self.getSubtitles()
|
||||||
|
self.assertEqual(set(subtitles.keys()), set(['en']))
|
||||||
|
self.assertEqual(md5(subtitles['en']), '97e7670cbae3c4d26ae8bcc7fdd78d4b')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
from .subtitles import SubtitlesInfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_str,
|
compat_str,
|
||||||
)
|
)
|
||||||
@ -22,7 +22,7 @@
|
|||||||
_x = lambda p: xpath_with_ns(p, {'smil': 'http://www.w3.org/2005/SMIL21/Language'})
|
_x = lambda p: xpath_with_ns(p, {'smil': 'http://www.w3.org/2005/SMIL21/Language'})
|
||||||
|
|
||||||
|
|
||||||
class ThePlatformIE(SubtitlesInfoExtractor):
|
class ThePlatformIE(InfoExtractor):
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
(?:https?://(?:link|player)\.theplatform\.com/[sp]/(?P<provider_id>[^/]+)/
|
(?:https?://(?:link|player)\.theplatform\.com/[sp]/(?P<provider_id>[^/]+)/
|
||||||
(?P<config>(?:[^/\?]+/(?:swf|config)|onsite)/select/)?
|
(?P<config>(?:[^/\?]+/(?:swf|config)|onsite)/select/)?
|
||||||
@ -104,15 +104,11 @@ def _real_extract(self, url):
|
|||||||
captions = info.get('captions')
|
captions = info.get('captions')
|
||||||
if isinstance(captions, list):
|
if isinstance(captions, list):
|
||||||
for caption in captions:
|
for caption in captions:
|
||||||
lang, src = caption.get('lang'), caption.get('src')
|
lang, src, mime = caption.get('lang', 'en'), caption.get('src'), caption.get('type')
|
||||||
if lang and src:
|
subtitles[lang] = [{
|
||||||
subtitles[lang] = src
|
'ext': 'srt' if mime == 'text/srt' else 'ttml',
|
||||||
|
'url': src,
|
||||||
if self._downloader.params.get('listsubtitles', False):
|
}]
|
||||||
self._list_available_subtitles(video_id, subtitles)
|
|
||||||
return
|
|
||||||
|
|
||||||
subtitles = self.extract_subtitles(video_id, subtitles)
|
|
||||||
|
|
||||||
head = meta.find(_x('smil:head'))
|
head = meta.find(_x('smil:head'))
|
||||||
body = meta.find(_x('smil:body'))
|
body = meta.find(_x('smil:body'))
|
||||||
|
Loading…
Reference in New Issue
Block a user