[ie/tele5] Overhaul extractor (#10024)

Closes #3051, Closes #7955, Closes #8501, Closes #9792
Authored by: bashonly
pull/9478/merge
bashonly 7 months ago committed by GitHub
parent 90d2da311b
commit c92e4e625e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,89 +1,77 @@
from .dplay import DPlayIE import functools
from ..compat import compat_urlparse
from ..utils import (
ExtractorError,
extract_attributes,
)
from .dplay import DiscoveryPlusBaseIE
from ..utils import join_nonempty
from ..utils.traversal import traverse_obj
class Tele5IE(DPlayIE): # XXX: Do not subclass from concrete IE
_WORKING = False class Tele5IE(DiscoveryPlusBaseIE):
_VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)' _VALID_URL = r'https?://(?:www\.)?tele5\.de/(?P<parent_slug>[\w-]+)/(?P<slug_a>[\w-]+)(?:/(?P<slug_b>[\w-]+))?'
_GEO_COUNTRIES = ['DE']
_TESTS = [{ _TESTS = [{
'url': 'https://www.tele5.de/mediathek/filme-online/videos?vid=1549416', # slug_a and slug_b
'url': 'https://tele5.de/mediathek/stargate-atlantis/quarantane',
'info_dict': { 'info_dict': {
'id': '1549416', 'id': '6852024',
'ext': 'mp4', 'ext': 'mp4',
'upload_date': '20180814', 'title': 'Quarantäne',
'timestamp': 1534290623, 'description': 'md5:6af0373bd0fcc4f13e5d47701903d675',
'title': 'Pandorum', 'episode': 'Episode 73',
}, 'episode_number': 73,
'params': { 'season': 'Season 4',
'skip_download': True, 'season_number': 4,
'series': 'Stargate Atlantis',
'upload_date': '20240525',
'timestamp': 1716643200,
'duration': 2503.2,
'thumbnail': 'https://eu1-prod-images.disco-api.com/2024/05/21/c81fcb45-8902-309b-badb-4e6d546b575d.jpeg',
'creators': ['Tele5'],
'tags': [],
}, },
'skip': 'No longer available: "404 Seite nicht gefunden"',
}, { }, {
# jwplatform, nexx unavailable # only slug_a
'url': 'https://www.tele5.de/filme/ghoul-das-geheimnis-des-friedhofmonsters/', 'url': 'https://tele5.de/mediathek/inside-out',
'info_dict': { 'info_dict': {
'id': 'WJuiOlUp', 'id': '6819502',
'ext': 'mp4', 'ext': 'mp4',
'upload_date': '20200603', 'title': 'Inside out',
'timestamp': 1591214400, 'description': 'md5:7e5f32ed0be5ddbd27713a34b9293bfd',
'title': 'Ghoul - Das Geheimnis des Friedhofmonsters', 'series': 'Inside out',
'description': 'md5:42002af1d887ff3d5b2b3ca1f8137d97', 'upload_date': '20240523',
'timestamp': 1716494400,
'duration': 5343.4,
'thumbnail': 'https://eu1-prod-images.disco-api.com/2024/05/15/181eba3c-f9f0-3faf-b14d-0097050a3aa4.jpeg',
'creators': ['Tele5'],
'tags': [],
}, },
'params': {
'skip_download': True,
},
'skip': 'No longer available, redirects to Filme page',
}, { }, {
'url': 'https://tele5.de/mediathek/angel-of-mine/', # playlist
'url': 'https://tele5.de/mediathek/schlefaz',
'info_dict': { 'info_dict': {
'id': '1252360', 'id': 'mediathek-schlefaz',
'ext': 'mp4',
'upload_date': '20220109',
'timestamp': 1641762000,
'title': 'Angel of Mine',
'description': 'md5:a72546a175e1286eb3251843a52d1ad7',
}, },
'params': { 'playlist_mincount': 3,
'format': 'bestvideo',
},
}, {
'url': 'https://www.tele5.de/kalkofes-mattscheibe/video-clips/politik-und-gesellschaft?ve_id=1551191',
'only_matching': True,
}, {
'url': 'https://www.tele5.de/video-clip/?ve_id=1609440',
'only_matching': True,
}, {
'url': 'https://www.tele5.de/filme/schlefaz-dragon-crusaders/',
'only_matching': True,
}, {
'url': 'https://www.tele5.de/filme/making-of/avengers-endgame/',
'only_matching': True,
}, {
'url': 'https://www.tele5.de/star-trek/raumschiff-voyager/ganze-folge/das-vinculum/',
'only_matching': True,
}, {
'url': 'https://www.tele5.de/anders-ist-sevda/',
'only_matching': True,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) parent_slug, slug_a, slug_b = self._match_valid_url(url).group('parent_slug', 'slug_a', 'slug_b')
webpage = self._download_webpage(url, video_id) playlist_id = join_nonempty(parent_slug, slug_a, slug_b, delim='-')
player_element = self._search_regex(r'(<hyoga-player\b[^>]+?>)', webpage, 'video player')
player_info = extract_attributes(player_element) query = {'environment': 'tele5', 'v': '2'}
asset_id, country, realm = (player_info[x] for x in ('assetid', 'locale', 'realm', )) if not slug_b:
endpoint = compat_urlparse.urlparse(player_info['endpoint']).hostname endpoint = f'page/{slug_a}'
source_type = player_info.get('sourcetype') query['parent_slug'] = parent_slug
if source_type: else:
endpoint = '%s-%s' % (source_type, endpoint) endpoint = f'videos/{slug_b}'
try: query['filter[show.slug]'] = slug_a
return self._get_disco_api_info(url, asset_id, endpoint, realm, country) cms_data = self._download_json(f'https://de-api.loma-cms.com/feloma/{endpoint}/', playlist_id, query=query)
except ExtractorError as e:
if getattr(e, 'message', '') == 'Missing deviceId in context': return self.playlist_result(map(
self.report_drm(video_id) functools.partial(self._get_disco_api_info, url, disco_host='eu1-prod.disco-api.com', realm='dmaxde', country='DE'),
raise traverse_obj(cms_data, ('blocks', ..., 'videoId', {str}))), playlist_id)
def _update_disco_api_headers(self, headers, disco_base, display_id, realm):
headers.update({
'x-disco-params': f'realm={realm}',
'x-disco-client': 'Alps:HyogaPlayer:0.0.0',
'Authorization': self._get_auth(disco_base, display_id, realm),
})

Loading…
Cancel
Save