]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/muenchentv.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / muenchentv.py
CommitLineData
7267bd53
PH
1import json
2
3from .common import InfoExtractor
4from ..utils import (
5 determine_ext,
6 int_or_none,
7 js_to_json,
8)
9
10
11class MuenchenTVIE(InfoExtractor):
df773c3d 12 _WORKING = False
7267bd53
PH
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,
add96eb9 23 'thumbnail': r're:^https?://.*\.jpg$',
7267bd53
PH
24 },
25 'params': {
26 'skip_download': True,
add96eb9 27 },
7267bd53
PH
28 }
29
30 def _real_extract(self, url):
31 display_id = 'live'
32 webpage = self._download_webpage(url, display_id)
33
39ca3b5c 34 title = self._og_search_title(webpage)
7267bd53
PH
35
36 data_js = self._search_regex(
6a26c5f9 37 r'(?s)\nplaylist:\s*(\[.*?}\]),',
7267bd53
PH
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:
add96eb9 50 label_str = f'_{format_num}'
7267bd53
PH
51
52 if ext is None:
53 format_id = label_str
54 else:
add96eb9 55 format_id = f'{ext}-{label_str}'
7267bd53
PH
56
57 formats.append({
58 'url': s['file'],
59 'tbr': int_or_none(s.get('label')),
60 'ext': 'mp4',
61 'format_id': format_id,
f983b875 62 'preference': -100 if '.smil' in s['file'] else 0, # Strictly inferior than all other formats?
7267bd53 63 })
7267bd53
PH
64
65 return {
66 'id': video_id,
67 'display_id': display_id,
68 'title': title,
69 'formats': formats,
70 'is_live': True,
c8417897 71 'thumbnail': thumbnail,
7267bd53 72 }