logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

rbmaradio.py (2406B)


  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|redbullradio)\.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 at Primavera Sound',
  20. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  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, 192, 256)]
  47. self._check_formats(formats, episode_id)
  48. description = clean_html(episode.get('longTeaser'))
  49. thumbnail = self._proto_relative_url(episode.get('imageURL', {}).get('landscape'))
  50. duration = int_or_none(episode.get('duration'))
  51. timestamp = unified_timestamp(episode.get('publishedAt'))
  52. return {
  53. 'id': episode_id,
  54. 'title': title,
  55. 'description': description,
  56. 'thumbnail': thumbnail,
  57. 'duration': duration,
  58. 'timestamp': timestamp,
  59. 'formats': formats,
  60. }