]>
Commit | Line | Data |
---|---|---|
1 | import json | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | determine_ext, | |
6 | int_or_none, | |
7 | js_to_json, | |
8 | ) | |
9 | ||
10 | ||
11 | class MuenchenTVIE(InfoExtractor): | |
12 | _WORKING = False | |
13 | _VALID_URL = r'https?://(?:www\.)?muenchen\.tv/livestream' | |
14 | IE_DESC = 'münchen.tv' | |
15 | _TEST = { | |
16 | 'url': 'http://www.muenchen.tv/livestream/', | |
17 | 'info_dict': { | |
18 | 'id': '5334', | |
19 | 'display_id': 'live', | |
20 | 'ext': 'mp4', | |
21 | 'title': 're:^münchen.tv-Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', | |
22 | 'is_live': True, | |
23 | 'thumbnail': r're:^https?://.*\.jpg$', | |
24 | }, | |
25 | 'params': { | |
26 | 'skip_download': True, | |
27 | }, | |
28 | } | |
29 | ||
30 | def _real_extract(self, url): | |
31 | display_id = 'live' | |
32 | webpage = self._download_webpage(url, display_id) | |
33 | ||
34 | title = self._og_search_title(webpage) | |
35 | ||
36 | data_js = self._search_regex( | |
37 | r'(?s)\nplaylist:\s*(\[.*?}\]),', | |
38 | webpage, 'playlist configuration') | |
39 | data_json = js_to_json(data_js) | |
40 | data = json.loads(data_json)[0] | |
41 | ||
42 | video_id = data['mediaid'] | |
43 | thumbnail = data.get('image') | |
44 | ||
45 | formats = [] | |
46 | for format_num, s in enumerate(data['sources']): | |
47 | ext = determine_ext(s['file'], None) | |
48 | label_str = s.get('label') | |
49 | if label_str is None: | |
50 | label_str = f'_{format_num}' | |
51 | ||
52 | if ext is None: | |
53 | format_id = label_str | |
54 | else: | |
55 | format_id = f'{ext}-{label_str}' | |
56 | ||
57 | formats.append({ | |
58 | 'url': s['file'], | |
59 | 'tbr': int_or_none(s.get('label')), | |
60 | 'ext': 'mp4', | |
61 | 'format_id': format_id, | |
62 | 'preference': -100 if '.smil' in s['file'] else 0, # Strictly inferior than all other formats? | |
63 | }) | |
64 | ||
65 | return { | |
66 | 'id': video_id, | |
67 | 'display_id': display_id, | |
68 | 'title': title, | |
69 | 'formats': formats, | |
70 | 'is_live': True, | |
71 | 'thumbnail': thumbnail, | |
72 | } |