mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 13:37:15 +08:00
[televizeseznam] add support for televizeseznam.cz
This commit is contained in:
parent
3fc56635b7
commit
8940aa036b
@ -1110,6 +1110,7 @@ from .telequebec import (
|
||||
TeleQuebecLiveIE,
|
||||
)
|
||||
from .teletask import TeleTaskIE
|
||||
from .televizeseznam import TelevizeSeznamIE
|
||||
from .telewebion import TelewebionIE
|
||||
from .tennistv import TennisTVIE
|
||||
from .tenplay import TenPlayIE
|
||||
|
85
youtube_dl/extractor/televizeseznam.py
Normal file
85
youtube_dl/extractor/televizeseznam.py
Normal file
@ -0,0 +1,85 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import compat_urlparse
|
||||
|
||||
|
||||
class TelevizeSeznamIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?televizeseznam\.cz/video/.+/(?P<id>.+)'
|
||||
|
||||
_API_BASE = 'https://www.televizeseznam.cz'
|
||||
_GRAPHQL_URL = '%s/api/graphql' % _API_BASE
|
||||
_GRAPHQL_QUERY = '''query LoadEpisode($urlName : String){ episode(urlName: $urlName){ ...VideoDetailFragmentOnEpisode } }
|
||||
fragment VideoDetailFragmentOnEpisode on Episode {
|
||||
id
|
||||
spl
|
||||
urlName
|
||||
name
|
||||
perex
|
||||
}
|
||||
'''
|
||||
|
||||
_TEST = {
|
||||
'url': 'https://www.televizeseznam.cz/video/lajna/buh-57953890',
|
||||
'md5': '40c41ade1464a390a0b447e333df4239',
|
||||
'info_dict': {
|
||||
'id': 'buh-57953890',
|
||||
'title': 'Bůh',
|
||||
'ext': 'mp4',
|
||||
}
|
||||
}
|
||||
|
||||
def extract_subtitles(self, spl_url, play_list):
|
||||
|
||||
if not play_list:
|
||||
return None
|
||||
|
||||
subtitles = {}
|
||||
for k, v in play_list.items():
|
||||
subtitles.update({
|
||||
v['language']: {
|
||||
'ext': 'srt',
|
||||
'url': compat_urlparse.urljoin(spl_url, v['urls']['srt'])
|
||||
}
|
||||
})
|
||||
return subtitles
|
||||
|
||||
def extract_formats(self, spl_url, play_list, subtitles):
|
||||
formats = []
|
||||
for r, v in play_list.items():
|
||||
formats.append({
|
||||
'url': compat_urlparse.urljoin(spl_url, v['url']),
|
||||
'width': v['resolution'][0],
|
||||
'height': v['resolution'][1],
|
||||
'resolution': '%sx%s' % (v['resolution'][0], v['resolution'][1]),
|
||||
'protocol': 'https',
|
||||
'ext': 'mp4',
|
||||
'subtitles': subtitles,
|
||||
})
|
||||
return formats
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
|
||||
data = self._download_json(
|
||||
self._GRAPHQL_URL, video_id, 'Downloading GraphQL result',
|
||||
data=json.dumps({
|
||||
'query': self._GRAPHQL_QUERY,
|
||||
'variables': {'urlName': video_id}
|
||||
}).encode('utf-8'),
|
||||
headers={'Content-Type': 'application/json;charset=UTF-8'}
|
||||
)['data']
|
||||
|
||||
spl_url = data['episode']['spl']
|
||||
play_list = self._download_json(spl_url + 'spl2,3', video_id, 'Downloading playlist')['data']
|
||||
subtitles = self.extract_subtitles(spl_url, play_list.get('subtitles'))
|
||||
formats = self.extract_formats(spl_url, play_list['mp4'], subtitles)
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': data['episode'].get('name'),
|
||||
'formats': formats
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user