]>
Commit | Line | Data |
---|---|---|
0e2a436d PH |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
56ba69e4 | 4 | from ..utils import parse_duration, unified_strdate |
0e2a436d PH |
5 | |
6 | ||
7 | class RadioFranceIE(InfoExtractor): | |
8 | _VALID_URL = r'^https?://maison\.radiofrance\.fr/radiovisions/(?P<id>[^?#]+)' | |
51fb2e98 | 9 | IE_NAME = 'radiofrance' |
0e2a436d PH |
10 | |
11 | _TEST = { | |
51fb2e98 PH |
12 | 'url': 'http://maison.radiofrance.fr/radiovisions/one-one', |
13 | 'md5': 'bdbb28ace95ed0e04faab32ba3160daf', | |
14 | 'info_dict': { | |
15 | 'id': 'one-one', | |
16 | 'ext': 'ogg', | |
611c1dd9 S |
17 | 'title': 'One to one', |
18 | 'description': "Plutôt que d'imaginer la radio de demain comme technologie ou comme création de contenu, je veux montrer que quelles que soient ses évolutions, j'ai l'intime conviction que la radio continuera d'être un grand média de proximité pour les auditeurs.", | |
19 | 'uploader': 'Thomas Hercouët', | |
0e2a436d PH |
20 | }, |
21 | } | |
22 | ||
23 | def _real_extract(self, url): | |
5ad28e7f | 24 | m = self._match_valid_url(url) |
0e2a436d PH |
25 | video_id = m.group('id') |
26 | ||
27 | webpage = self._download_webpage(url, video_id) | |
51fb2e98 | 28 | title = self._html_search_regex(r'<h1>(.*?)</h1>', webpage, 'title') |
0e2a436d PH |
29 | description = self._html_search_regex( |
30 | r'<div class="bloc_page_wrapper"><div class="text">(.*?)</div>', | |
51fb2e98 | 31 | webpage, 'description', fatal=False) |
0e2a436d PH |
32 | uploader = self._html_search_regex( |
33 | r'<div class="credit"> © (.*?)</div>', | |
51fb2e98 | 34 | webpage, 'uploader', fatal=False) |
0e2a436d PH |
35 | |
36 | formats_str = self._html_search_regex( | |
37 | r'class="jp-jplayer[^"]*" data-source="([^"]+)">', | |
51fb2e98 | 38 | webpage, 'audio URLs') |
0e2a436d PH |
39 | formats = [ |
40 | { | |
7de6e075 PH |
41 | 'format_id': fm[0], |
42 | 'url': fm[1], | |
0e2a436d | 43 | 'vcodec': 'none', |
f983b875 | 44 | 'quality': i, |
0e2a436d | 45 | } |
51fb2e98 PH |
46 | for i, fm in |
47 | enumerate(re.findall(r"([a-z0-9]+)\s*:\s*'([^']+)'", formats_str)) | |
0e2a436d | 48 | ] |
0e2a436d PH |
49 | |
50 | return { | |
51 | 'id': video_id, | |
52 | 'title': title, | |
53 | 'formats': formats, | |
54 | 'description': description, | |
55 | 'uploader': uploader, | |
56 | } | |
56ba69e4 | 57 | |
58 | ||
59 | class FranceCultureIE(InfoExtractor): | |
38d86f4d | 60 | _VALID_URL = r'https?://(?:www\.)?radiofrance\.fr/(?:franceculture|fip|francemusique|mouv|franceinter)/podcasts/(?:[^?#]+/)?(?P<display_id>[^?#]+)-(?P<id>\d+)($|[?#])' |
56ba69e4 | 61 | _TESTS = [ |
62 | { | |
63 | 'url': 'https://www.radiofrance.fr/franceculture/podcasts/science-en-questions/la-physique-d-einstein-aiderait-elle-a-comprendre-le-cerveau-8440487', | |
64 | 'info_dict': { | |
65 | 'id': '8440487', | |
66 | 'display_id': 'la-physique-d-einstein-aiderait-elle-a-comprendre-le-cerveau', | |
67 | 'ext': 'mp3', | |
68 | 'title': 'La physique d’Einstein aiderait-elle à comprendre le cerveau ?', | |
69 | 'description': 'Existerait-il un pont conceptuel entre la physique de l’espace-temps et les neurosciences ?', | |
70 | 'thumbnail': 'https://cdn.radiofrance.fr/s3/cruiser-production/2022/05/d184e7a3-4827-4494-bf94-04ed7b120db4/1200x630_gettyimages-200171095-001.jpg', | |
71 | 'upload_date': '20220514', | |
72 | 'duration': 2750, | |
73 | }, | |
74 | }, | |
38d86f4d | 75 | { |
76 | 'url': 'https://www.radiofrance.fr/franceinter/podcasts/la-rafle-du-vel-d-hiv-une-affaire-d-etat/les-racines-du-crime-episode-1-3715507', | |
77 | 'only_matching': True, | |
78 | } | |
56ba69e4 | 79 | ] |
80 | ||
81 | def _real_extract(self, url): | |
82 | video_id, display_id = self._match_valid_url(url).group('id', 'display_id') | |
83 | webpage = self._download_webpage(url, display_id) | |
84 | ||
85 | # _search_json_ld doesn't correctly handle this. See https://github.com/yt-dlp/yt-dlp/pull/3874#discussion_r891903846 | |
8b7fb8b6 | 86 | video_data = self._search_json('', webpage, 'audio data', display_id, contains_pattern=r'{\s*"@type"\s*:\s*"AudioObject".+}') |
56ba69e4 | 87 | |
88 | return { | |
89 | 'id': video_id, | |
90 | 'display_id': display_id, | |
91 | 'url': video_data['contentUrl'], | |
92 | 'ext': video_data.get('encodingFormat'), | |
93 | 'vcodec': 'none' if video_data.get('encodingFormat') == 'mp3' else None, | |
94 | 'duration': parse_duration(video_data.get('duration')), | |
95 | 'title': self._html_search_regex(r'(?s)<h1[^>]*itemprop="[^"]*name[^"]*"[^>]*>(.+?)</h1>', | |
96 | webpage, 'title', default=self._og_search_title(webpage)), | |
97 | 'description': self._html_search_regex( | |
98 | r'(?s)<meta name="description"\s*content="([^"]+)', webpage, 'description', default=None), | |
99 | 'thumbnail': self._og_search_thumbnail(webpage), | |
100 | 'uploader': self._html_search_regex( | |
101 | r'(?s)<span class="author">(.*?)</span>', webpage, 'uploader', default=None), | |
102 | 'upload_date': unified_strdate(self._search_regex( | |
103 | r'"datePublished"\s*:\s*"([^"]+)', webpage, 'timestamp', fatal=False)) | |
104 | } |