yt-dlp/youtube_dl/extractor/rbmaradio.py

47 lines
1.7 KiB
Python
Raw Normal View History

# encoding: utf-8
from __future__ import unicode_literals
2013-06-23 20:09:32 +00:00
from .common import InfoExtractor
from ..utils import (
2016-08-06 13:26:48 +00:00
clean_html
2013-06-23 20:09:32 +00:00
)
class RBMARadioIE(InfoExtractor):
2016-08-06 13:26:48 +00:00
_VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/[^/]+/episodes/(?P<id>[^/]+)$'
2013-06-27 18:46:46 +00:00
_TEST = {
2016-08-06 13:26:48 +00:00
'url': 'https://www.rbmaradio.com/shows/main-stage/episodes/ford-lopatin-live-at-primavera-sound-2011',
'md5': '6bc6f9bcb18994b4c983bc3bf4384d95',
'info_dict': {
2014-02-02 11:03:36 +00:00
'id': 'ford-lopatin-live-at-primavera-sound-2011',
'ext': 'mp3',
2016-02-14 09:37:17 +00:00
'description': 'Joel Ford and Daniel Oneohtrix Point Never Lopatin fly their midified pop extravaganza to Spain. Live at Primavera Sound 2011.',
2016-08-06 13:26:48 +00:00
'title': 'Ford & Lopatin - Main Stage',
},
2013-06-27 18:46:46 +00:00
}
2013-06-23 20:09:32 +00:00
def _real_extract(self, url):
2016-08-06 13:26:48 +00:00
video_id = self._match_id(url)
2013-06-23 20:09:32 +00:00
webpage = self._download_webpage(url, video_id)
2016-08-06 13:26:48 +00:00
json_data = self._search_regex(r'<script>window\.__INITIAL_STATE__\s*=\s*(.+?)</script>',
webpage, 'json data')
data = self._parse_json(json_data, video_id)
2013-06-23 20:09:32 +00:00
2016-08-06 13:26:48 +00:00
item = None
for episode in data['episodes']:
items = data['episodes'][episode]
if video_id in items:
item = items[video_id]
2013-06-23 20:09:32 +00:00
2016-08-06 13:26:48 +00:00
video_url = item['audioURL'] + '?cbr=256'
return {
'id': video_id,
'url': video_url,
2016-08-06 13:26:48 +00:00
'title': item.get('title') + ' - ' + item.get('showTitle'),
'description': clean_html(item.get('longTeaser')),
'thumbnail': self._proto_relative_url(item.get('imageURL', {}).get('landscape')),
'duration': item.get('duration'),
2013-06-23 20:09:32 +00:00
}