]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/rbmaradio.py
Merge pull request #8061 from dstftw/introduce-chapter-and-series-fields
[yt-dlp.git] / youtube_dl / extractor / rbmaradio.py
CommitLineData
245b612a
JMF
1# encoding: utf-8
2from __future__ import unicode_literals
3
e10e576f
PH
4import json
5import re
6
7from .common import InfoExtractor
8from ..utils import (
e10e576f
PH
9 ExtractorError,
10)
11
12
13class RBMARadioIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
6f5ac90c 15 _TEST = {
245b612a 16 'url': 'http://www.rbmaradio.com/shows/ford-lopatin-live-at-primavera-sound-2011',
245b612a
JMF
17 'md5': '6bc6f9bcb18994b4c983bc3bf4384d95',
18 'info_dict': {
d55433bb
PH
19 'id': 'ford-lopatin-live-at-primavera-sound-2011',
20 'ext': 'mp3',
245b612a
JMF
21 "uploader_id": "ford-lopatin",
22 "location": "Spain",
23 "description": "Joel Ford and Daniel ’Oneohtrix Point Never’ Lopatin fly their midified pop extravaganza to Spain. Live at Primavera Sound 2011.",
24 "uploader": "Ford & Lopatin",
25 "title": "Live at Primavera Sound 2011",
26 },
6f5ac90c 27 }
e10e576f
PH
28
29 def _real_extract(self, url):
30 m = re.match(self._VALID_URL, url)
31 video_id = m.group('videoID')
32
33 webpage = self._download_webpage(url, video_id)
34
35 json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
9e1a5b84 36 webpage, 'json data', flags=re.MULTILINE)
e10e576f
PH
37
38 try:
39 data = json.loads(json_data)
40 except ValueError as e:
245b612a 41 raise ExtractorError('Invalid JSON: ' + str(e))
e10e576f
PH
42
43 video_url = data['akamai_url'] + '&cbr=256'
245b612a
JMF
44
45 return {
46 'id': video_id,
47 'url': video_url,
48 'title': data['title'],
49 'description': data.get('teaser_text'),
50 'location': data.get('country_of_origin'),
51 'uploader': data.get('host', {}).get('name'),
52 'uploader_id': data.get('host', {}).get('slug'),
53 'thumbnail': data.get('image', {}).get('large_url_2x'),
54 'duration': data.get('duration'),
e10e576f 55 }