]>
Commit | Line | Data |
---|---|---|
7232e548 RA |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
34921b43 | 5 | from ..utils import int_or_none, join_nonempty |
7232e548 RA |
6 | |
7 | ||
8 | class TOnlineIE(InfoExtractor): | |
9 | IE_NAME = 't-online.de' | |
10 | _VALID_URL = r'https?://(?:www\.)?t-online\.de/tv/(?:[^/]+/)*id_(?P<id>\d+)' | |
11 | _TEST = { | |
12 | 'url': 'http://www.t-online.de/tv/sport/fussball/id_79166266/drittes-remis-zidane-es-muss-etwas-passieren-.html', | |
13 | 'md5': '7d94dbdde5f9d77c5accc73c39632c29', | |
14 | 'info_dict': { | |
15 | 'id': '79166266', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'Drittes Remis! Zidane: "Es muss etwas passieren"', | |
18 | '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.', | |
19 | } | |
20 | } | |
21 | ||
22 | def _real_extract(self, url): | |
23 | video_id = self._match_id(url) | |
24 | video_data = self._download_json( | |
25 | 'http://www.t-online.de/tv/id_%s/tid_json_video' % video_id, video_id) | |
26 | title = video_data['subtitle'] | |
27 | ||
28 | formats = [] | |
29 | for asset in video_data.get('assets', []): | |
30 | asset_source = asset.get('source') or asset.get('source2') | |
31 | if not asset_source: | |
32 | continue | |
7232e548 | 33 | formats.append({ |
34921b43 | 34 | 'format_id': join_nonempty('type', 'profile', from_dict=asset), |
7232e548 RA |
35 | 'url': asset_source, |
36 | }) | |
37 | ||
38 | thumbnails = [] | |
39 | for image in video_data.get('images', []): | |
40 | image_source = image.get('source') | |
41 | if not image_source: | |
42 | continue | |
43 | thumbnails.append({ | |
44 | 'url': image_source, | |
45 | }) | |
46 | ||
47 | return { | |
48 | 'id': video_id, | |
49 | 'title': title, | |
50 | 'description': video_data.get('description'), | |
51 | 'duration': int_or_none(video_data.get('duration')), | |
52 | 'thumbnails': thumbnails, | |
53 | 'formats': formats, | |
54 | } |