]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/radiode.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / radiode.py
CommitLineData
6d088620
S
1from .common import InfoExtractor
2
3
4class RadioDeIE(InfoExtractor):
df773c3d 5 _WORKING = False
6d088620
S
6 IE_NAME = 'radio.de'
7 _VALID_URL = r'https?://(?P<id>.+?)\.(?:radio\.(?:de|at|fr|pt|es|pl|it)|rad\.io)'
8 _TEST = {
9 'url': 'http://ndr2.radio.de/',
6d088620
S
10 'info_dict': {
11 'id': 'ndr2',
12 'ext': 'mp3',
13 'title': 're:^NDR 2 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
14 'description': 'md5:591c49c702db1a33751625ebfb67f273',
ec85ded8 15 'thumbnail': r're:^https?://.*\.png',
98f00040 16 'is_live': True,
6d088620
S
17 },
18 'params': {
19 'skip_download': True,
add96eb9 20 },
6d088620
S
21 }
22
23 def _real_extract(self, url):
24 radio_id = self._match_id(url)
6d088620 25 webpage = self._download_webpage(url, radio_id)
98f00040
PH
26 jscode = self._search_regex(
27 r"'components/station/stationService':\s*\{\s*'?station'?:\s*(\{.*?\s*\}),\n",
28 webpage, 'broadcast')
6d088620 29
98f00040 30 broadcast = self._parse_json(jscode, radio_id)
39ca3b5c 31 title = broadcast['name']
6d088620 32 description = broadcast.get('description') or broadcast.get('shortDescription')
98f00040 33 thumbnail = broadcast.get('picture4Url') or broadcast.get('picture4TransUrl') or broadcast.get('logo100x100')
6d088620
S
34
35 formats = [{
36 'url': stream['streamUrl'],
37 'ext': stream['streamContentFormat'].lower(),
38 'acodec': stream['streamContentFormat'],
39 'abr': stream['bitRate'],
add96eb9 40 'asr': stream['sampleRate'],
6d088620 41 } for stream in broadcast['streamUrls']]
6d088620
S
42
43 return {
44 'id': radio_id,
45 'title': title,
46 'description': description,
47 'thumbnail': thumbnail,
48 'is_live': True,
49 'formats': formats,
50 }