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.

57 lines
1.9 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. import re
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. compat_urllib_parse_urlparse,
  8. ExtractorError,
  9. )
  10. class RBMARadioIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  12. _TEST = {
  13. 'url': 'http://www.rbmaradio.com/shows/ford-lopatin-live-at-primavera-sound-2011',
  14. 'file': 'ford-lopatin-live-at-primavera-sound-2011.mp3',
  15. 'md5': '6bc6f9bcb18994b4c983bc3bf4384d95',
  16. 'info_dict': {
  17. "uploader_id": "ford-lopatin",
  18. "location": "Spain",
  19. "description": "Joel Ford and Daniel ’Oneohtrix Point Never’ Lopatin fly their midified pop extravaganza to Spain. Live at Primavera Sound 2011.",
  20. "uploader": "Ford & Lopatin",
  21. "title": "Live at Primavera Sound 2011",
  22. },
  23. }
  24. def _real_extract(self, url):
  25. m = re.match(self._VALID_URL, url)
  26. video_id = m.group('videoID')
  27. webpage = self._download_webpage(url, video_id)
  28. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  29. webpage, 'json data', flags=re.MULTILINE)
  30. try:
  31. data = json.loads(json_data)
  32. except ValueError as e:
  33. raise ExtractorError('Invalid JSON: ' + str(e))
  34. video_url = data['akamai_url'] + '&cbr=256'
  35. url_parts = compat_urllib_parse_urlparse(video_url)
  36. return {
  37. 'id': video_id,
  38. 'url': video_url,
  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. }