]>
Commit | Line | Data |
---|---|---|
6d088620 S |
1 | from .common import InfoExtractor |
2 | ||
3 | ||
4 | class 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']] | |
41 | self._sort_formats(formats) | |
42 | ||
43 | return { | |
44 | 'id': radio_id, | |
45 | 'title': title, | |
46 | 'description': description, | |
47 | 'thumbnail': thumbnail, | |
48 | 'is_live': True, | |
49 | 'formats': formats, | |
50 | } |