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.

55 lines
1.8 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. ExtractorError,
  8. )
  9. class RBMARadioIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  11. _TEST = {
  12. 'url': 'http://www.rbmaradio.com/shows/ford-lopatin-live-at-primavera-sound-2011',
  13. 'md5': '6bc6f9bcb18994b4c983bc3bf4384d95',
  14. 'info_dict': {
  15. 'id': 'ford-lopatin-live-at-primavera-sound-2011',
  16. 'ext': 'mp3',
  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. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'title': data['title'],
  39. 'description': data.get('teaser_text'),
  40. 'location': data.get('country_of_origin'),
  41. 'uploader': data.get('host', {}).get('name'),
  42. 'uploader_id': data.get('host', {}).get('slug'),
  43. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  44. 'duration': data.get('duration'),
  45. }