You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

  1. import json
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse_urlparse,
  6. ExtractorError,
  7. )
  8. class RBMARadioIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  10. def _real_extract(self, url):
  11. m = re.match(self._VALID_URL, url)
  12. video_id = m.group('videoID')
  13. webpage = self._download_webpage(url, video_id)
  14. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  15. webpage, u'json data', flags=re.MULTILINE)
  16. try:
  17. data = json.loads(json_data)
  18. except ValueError as e:
  19. raise ExtractorError(u'Invalid JSON: ' + str(e))
  20. video_url = data['akamai_url'] + '&cbr=256'
  21. url_parts = compat_urllib_parse_urlparse(video_url)
  22. video_ext = url_parts.path.rpartition('.')[2]
  23. info = {
  24. 'id': video_id,
  25. 'url': video_url,
  26. 'ext': video_ext,
  27. 'title': data['title'],
  28. 'description': data.get('teaser_text'),
  29. 'location': data.get('country_of_origin'),
  30. 'uploader': data.get('host', {}).get('name'),
  31. 'uploader_id': data.get('host', {}).get('slug'),
  32. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  33. 'duration': data.get('duration'),
  34. }
  35. return [info]