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