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.

71 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. clean_html,
  7. int_or_none,
  8. unified_timestamp,
  9. update_url_query,
  10. )
  11. class RBMARadioIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<show_id>[^/]+)/episodes/(?P<id>[^/?#&]+)'
  13. _TEST = {
  14. 'url': 'https://www.rbmaradio.com/shows/main-stage/episodes/ford-lopatin-live-at-primavera-sound-2011',
  15. 'md5': '6bc6f9bcb18994b4c983bc3bf4384d95',
  16. 'info_dict': {
  17. 'id': 'ford-lopatin-live-at-primavera-sound-2011',
  18. 'ext': 'mp3',
  19. 'title': 'Main Stage - Ford & Lopatin',
  20. 'description': 'md5:4f340fb48426423530af5a9d87bd7b91',
  21. 'thumbnail': r're:^https?://.*\.jpg',
  22. 'duration': 2452,
  23. 'timestamp': 1307103164,
  24. 'upload_date': '20110603',
  25. },
  26. }
  27. def _real_extract(self, url):
  28. mobj = re.match(self._VALID_URL, url)
  29. show_id = mobj.group('show_id')
  30. episode_id = mobj.group('id')
  31. webpage = self._download_webpage(url, episode_id)
  32. episode = self._parse_json(
  33. self._search_regex(
  34. r'__INITIAL_STATE__\s*=\s*({.+?})\s*</script>',
  35. webpage, 'json data'),
  36. episode_id)['episodes'][show_id][episode_id]
  37. title = episode['title']
  38. show_title = episode.get('showTitle')
  39. if show_title:
  40. title = '%s - %s' % (show_title, title)
  41. formats = [{
  42. 'url': update_url_query(episode['audioURL'], query={'cbr': abr}),
  43. 'format_id': compat_str(abr),
  44. 'abr': abr,
  45. 'vcodec': 'none',
  46. } for abr in (96, 128, 256)]
  47. description = clean_html(episode.get('longTeaser'))
  48. thumbnail = self._proto_relative_url(episode.get('imageURL', {}).get('landscape'))
  49. duration = int_or_none(episode.get('duration'))
  50. timestamp = unified_timestamp(episode.get('publishedAt'))
  51. return {
  52. 'id': episode_id,
  53. 'title': title,
  54. 'description': description,
  55. 'thumbnail': thumbnail,
  56. 'duration': duration,
  57. 'timestamp': timestamp,
  58. 'formats': formats,
  59. }