]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/tonline.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / tonline.py
CommitLineData
7232e548 1from .common import InfoExtractor
34921b43 2from ..utils import int_or_none, join_nonempty
7232e548
RA
3
4
5class TOnlineIE(InfoExtractor):
df773c3d 6 _WORKING = False
7 _ENABLED = None # XXX: pass through to GenericIE
7232e548
RA
8 IE_NAME = 't-online.de'
9 _VALID_URL = r'https?://(?:www\.)?t-online\.de/tv/(?:[^/]+/)*id_(?P<id>\d+)'
10 _TEST = {
11 'url': 'http://www.t-online.de/tv/sport/fussball/id_79166266/drittes-remis-zidane-es-muss-etwas-passieren-.html',
12 'md5': '7d94dbdde5f9d77c5accc73c39632c29',
13 'info_dict': {
14 'id': '79166266',
15 'ext': 'mp4',
16 'title': 'Drittes Remis! Zidane: "Es muss etwas passieren"',
17 'description': 'Es läuft nicht rund bei Real Madrid. Das 1:1 gegen den SD Eibar war das dritte Unentschieden in Folge in der Liga.',
add96eb9 18 },
7232e548
RA
19 }
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23 video_data = self._download_json(
add96eb9 24 f'http://www.t-online.de/tv/id_{video_id}/tid_json_video', video_id)
7232e548
RA
25 title = video_data['subtitle']
26
27 formats = []
28 for asset in video_data.get('assets', []):
29 asset_source = asset.get('source') or asset.get('source2')
30 if not asset_source:
31 continue
7232e548 32 formats.append({
34921b43 33 'format_id': join_nonempty('type', 'profile', from_dict=asset),
7232e548
RA
34 'url': asset_source,
35 })
36
37 thumbnails = []
38 for image in video_data.get('images', []):
39 image_source = image.get('source')
40 if not image_source:
41 continue
42 thumbnails.append({
43 'url': image_source,
44 })
45
46 return {
47 'id': video_id,
48 'title': title,
49 'description': video_data.get('description'),
50 'duration': int_or_none(video_data.get('duration')),
51 'thumbnails': thumbnails,
52 'formats': formats,
53 }