[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / radiode.py
blob1bf74495113e07a6a38279e8307833cd9ff0452a
1 from .common import InfoExtractor
4 class RadioDeIE(InfoExtractor):
5 _WORKING = False
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/',
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',
15 'thumbnail': r're:^https?://.*\.png',
16 'is_live': True,
18 'params': {
19 'skip_download': True,
23 def _real_extract(self, url):
24 radio_id = self._match_id(url)
25 webpage = self._download_webpage(url, radio_id)
26 jscode = self._search_regex(
27 r"'components/station/stationService':\s*\{\s*'?station'?:\s*(\{.*?\s*\}),\n",
28 webpage, 'broadcast')
30 broadcast = self._parse_json(jscode, radio_id)
31 title = broadcast['name']
32 description = broadcast.get('description') or broadcast.get('shortDescription')
33 thumbnail = broadcast.get('picture4Url') or broadcast.get('picture4TransUrl') or broadcast.get('logo100x100')
35 formats = [{
36 'url': stream['streamUrl'],
37 'ext': stream['streamContentFormat'].lower(),
38 'acodec': stream['streamContentFormat'],
39 'abr': stream['bitRate'],
40 'asr': stream['sampleRate'],
41 } for stream in broadcast['streamUrls']]
43 return {
44 'id': radio_id,
45 'title': title,
46 'description': description,
47 'thumbnail': thumbnail,
48 'is_live': True,
49 'formats': formats,