rtrfm.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from .common import InfoExtractor
  2. class RTRFMIE(InfoExtractor):
  3. _VALID_URL = r'https?://(?:www\.)?rtrfm\.com\.au/(?:shows|show-episode)/(?P<id>[^/?\#&]+)'
  4. _TESTS = [
  5. {
  6. 'url': 'https://rtrfm.com.au/shows/breakfast/',
  7. 'md5': '46168394d3a5ce237cf47e85d0745413',
  8. 'info_dict': {
  9. 'id': 'breakfast-2021-11-16',
  10. 'ext': 'mp3',
  11. 'series': 'Breakfast with Taylah',
  12. 'title': r're:^Breakfast with Taylah \d{4}-\d{2}-\d{2}$',
  13. 'description': 'md5:0979c3ab1febfbec3f1ccb743633c611',
  14. },
  15. 'skip': 'ID and md5 changes daily',
  16. },
  17. {
  18. 'url': 'https://rtrfm.com.au/show-episode/breakfast-2021-11-11/',
  19. 'md5': '396bedf1e40f96c62b30d4999202a790',
  20. 'info_dict': {
  21. 'id': 'breakfast-2021-11-11',
  22. 'ext': 'mp3',
  23. 'series': 'Breakfast with Taylah',
  24. 'title': 'Breakfast with Taylah 2021-11-11',
  25. 'description': 'md5:0979c3ab1febfbec3f1ccb743633c611',
  26. },
  27. },
  28. {
  29. 'url': 'https://rtrfm.com.au/show-episode/breakfast-2020-06-01/',
  30. 'md5': '594027f513ec36a24b15d65007a24dff',
  31. 'info_dict': {
  32. 'id': 'breakfast-2020-06-01',
  33. 'ext': 'mp3',
  34. 'series': 'Breakfast with Taylah',
  35. 'title': 'Breakfast with Taylah 2020-06-01',
  36. 'description': r're:^Breakfast with Taylah ',
  37. },
  38. 'skip': 'This audio has expired',
  39. },
  40. ]
  41. def _real_extract(self, url):
  42. display_id = self._match_id(url)
  43. webpage = self._download_webpage(url, display_id)
  44. show, date, title = self._search_regex(
  45. r'''\.playShow(?:From)?\(['"](?P<show>[^'"]+)['"],\s*['"](?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2})['"],\s*['"](?P<title>[^'"]+)['"]''',
  46. webpage, 'details', group=('show', 'date', 'title'))
  47. url = self._download_json(
  48. 'https://restreams.rtrfm.com.au/rzz',
  49. show, 'Downloading MP3 URL', query={'n': show, 'd': date})['u']
  50. # This is the only indicator of an error until trying to download the URL and
  51. # downloads of mp4 URLs always fail (403 for current episodes, 404 for missing).
  52. if '.mp4' in url:
  53. url = None
  54. self.raise_no_formats('Expired or no episode on this date', expected=True)
  55. return {
  56. 'id': f'{show}-{date}',
  57. 'title': f'{title} {date}',
  58. 'series': title,
  59. 'url': url,
  60. 'release_date': date,
  61. 'description': self._og_search_description(webpage),
  62. }