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.

56 lines
2.0 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. _TEST = {
  11. u'url': u'http://www.rbmaradio.com/shows/ford-lopatin-live-at-primavera-sound-2011',
  12. u'file': u'ford-lopatin-live-at-primavera-sound-2011.mp3',
  13. u'md5': u'6bc6f9bcb18994b4c983bc3bf4384d95',
  14. u'info_dict': {
  15. u"uploader_id": u"ford-lopatin",
  16. u"location": u"Spain",
  17. u"description": u"Joel Ford and Daniel \u2019Oneohtrix Point Never\u2019 Lopatin fly their midified pop extravaganza to Spain. Live at Primavera Sound 2011.",
  18. u"uploader": u"Ford & Lopatin",
  19. u"title": u"Live at Primavera Sound 2011"
  20. }
  21. }
  22. def _real_extract(self, url):
  23. m = re.match(self._VALID_URL, url)
  24. video_id = m.group('videoID')
  25. webpage = self._download_webpage(url, video_id)
  26. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  27. webpage, u'json data', flags=re.MULTILINE)
  28. try:
  29. data = json.loads(json_data)
  30. except ValueError as e:
  31. raise ExtractorError(u'Invalid JSON: ' + str(e))
  32. video_url = data['akamai_url'] + '&cbr=256'
  33. url_parts = compat_urllib_parse_urlparse(video_url)
  34. video_ext = url_parts.path.rpartition('.')[2]
  35. info = {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'ext': video_ext,
  39. 'title': data['title'],
  40. 'description': data.get('teaser_text'),
  41. 'location': data.get('country_of_origin'),
  42. 'uploader': data.get('host', {}).get('name'),
  43. 'uploader_id': data.get('host', {}).get('slug'),
  44. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  45. 'duration': data.get('duration'),
  46. }
  47. return [info]