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