]>
Commit | Line | Data |
---|---|---|
e10e576f | 1 | from .common import InfoExtractor |
3a380766 | 2 | from ..compat import compat_str |
e10e576f | 3 | from ..utils import ( |
3a380766 S |
4 | clean_html, |
5 | int_or_none, | |
6 | unified_timestamp, | |
7 | update_url_query, | |
e10e576f PH |
8 | ) |
9 | ||
10 | ||
11 | class RBMARadioIE(InfoExtractor): | |
95152630 | 12 | _VALID_URL = r'https?://(?:www\.)?(?:rbmaradio|redbullradio)\.com/shows/(?P<show_id>[^/]+)/episodes/(?P<id>[^/?#&]+)' |
6f5ac90c | 13 | _TEST = { |
affaea06 | 14 | 'url': 'https://www.rbmaradio.com/shows/main-stage/episodes/ford-lopatin-live-at-primavera-sound-2011', |
245b612a JMF |
15 | 'md5': '6bc6f9bcb18994b4c983bc3bf4384d95', |
16 | 'info_dict': { | |
d55433bb PH |
17 | 'id': 'ford-lopatin-live-at-primavera-sound-2011', |
18 | 'ext': 'mp3', | |
95152630 SM |
19 | 'title': 'Main Stage - Ford & Lopatin at Primavera Sound', |
20 | 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', | |
ec85ded8 | 21 | 'thumbnail': r're:^https?://.*\.jpg', |
3a380766 S |
22 | 'duration': 2452, |
23 | 'timestamp': 1307103164, | |
24 | 'upload_date': '20110603', | |
245b612a | 25 | }, |
6f5ac90c | 26 | } |
e10e576f PH |
27 | |
28 | def _real_extract(self, url): | |
5ad28e7f | 29 | mobj = self._match_valid_url(url) |
3a380766 S |
30 | show_id = mobj.group('show_id') |
31 | episode_id = mobj.group('id') | |
32 | ||
33 | webpage = self._download_webpage(url, episode_id) | |
34 | ||
35 | episode = self._parse_json( | |
36 | self._search_regex( | |
37 | r'__INITIAL_STATE__\s*=\s*({.+?})\s*</script>', | |
38 | webpage, 'json data'), | |
39 | episode_id)['episodes'][show_id][episode_id] | |
40 | ||
41 | title = episode['title'] | |
e10e576f | 42 | |
3a380766 S |
43 | show_title = episode.get('showTitle') |
44 | if show_title: | |
45 | title = '%s - %s' % (show_title, title) | |
e10e576f | 46 | |
3a380766 S |
47 | formats = [{ |
48 | 'url': update_url_query(episode['audioURL'], query={'cbr': abr}), | |
49 | 'format_id': compat_str(abr), | |
50 | 'abr': abr, | |
51 | 'vcodec': 'none', | |
2e190c2a | 52 | } for abr in (96, 128, 192, 256)] |
4fd1437d | 53 | self._check_formats(formats, episode_id) |
e10e576f | 54 | |
3a380766 S |
55 | description = clean_html(episode.get('longTeaser')) |
56 | thumbnail = self._proto_relative_url(episode.get('imageURL', {}).get('landscape')) | |
57 | duration = int_or_none(episode.get('duration')) | |
58 | timestamp = unified_timestamp(episode.get('publishedAt')) | |
245b612a JMF |
59 | |
60 | return { | |
3a380766 S |
61 | 'id': episode_id, |
62 | 'title': title, | |
63 | 'description': description, | |
64 | 'thumbnail': thumbnail, | |
65 | 'duration': duration, | |
66 | 'timestamp': timestamp, | |
67 | 'formats': formats, | |
e10e576f | 68 | } |