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