]>
Commit | Line | Data |
---|---|---|
cce929ea | 1 | from .common import InfoExtractor |
d05460e5 | 2 | from ..utils import int_or_none, parse_duration, unified_strdate |
cce929ea PH |
3 | |
4 | ||
5 | class FranceCultureIE(InfoExtractor): | |
d05460e5 AG |
6 | _VALID_URL = r'https?://(?:www\.)?radiofrance\.fr/franceculture/podcasts/(?:[^?#]+/)?(?P<display_id>[^?#]+)-(?P<id>\d+)($|[?#])' |
7 | _TESTS = [ | |
8 | { | |
9 | 'url': 'https://www.radiofrance.fr/franceculture/podcasts/science-en-questions/la-physique-d-einstein-aiderait-elle-a-comprendre-le-cerveau-8440487', | |
4b3c5d1b | 10 | 'info_dict': { |
d05460e5 AG |
11 | 'id': '8440487', |
12 | 'display_id': 'la-physique-d-einstein-aiderait-elle-a-comprendre-le-cerveau', | |
4b3c5d1b | 13 | 'ext': 'mp3', |
d05460e5 AG |
14 | 'title': 'La physique d’Einstein aiderait-elle à comprendre le cerveau ?', |
15 | 'description': 'Existerait-il un pont conceptuel entre la physique de l’espace-temps et les neurosciences ?', | |
16 | 'thumbnail': 'https://cdn.radiofrance.fr/s3/cruiser-production/2022/05/d184e7a3-4827-4494-bf94-04ed7b120db4/1200x630_gettyimages-200171095-001.jpg', | |
17 | 'upload_date': '20220514', | |
18 | 'duration': 2750, | |
4b3c5d1b B |
19 | }, |
20 | }, | |
d05460e5 | 21 | ] |
cce929ea | 22 | |
82997dad | 23 | def _real_extract(self, url): |
d05460e5 | 24 | video_id, display_id = self._match_valid_url(url).group('id', 'display_id') |
82997dad | 25 | webpage = self._download_webpage(url, display_id) |
cce929ea | 26 | |
d05460e5 AG |
27 | # _search_json_ld doesn't correctly handle this. See https://github.com/yt-dlp/yt-dlp/pull/3874#discussion_r891903846 |
28 | video_data = self._search_json('', webpage, 'audio data', display_id, contains_pattern=r'\s*"@type"\s*:\s*"AudioObject"\s*.+') | |
29 | ||
30 | return { | |
31 | 'id': video_id, | |
32 | 'display_id': display_id, | |
33 | 'url': video_data['contentUrl'], | |
34 | 'ext': video_data.get('encodingFormat'), | |
35 | 'vcodec': 'none' if video_data.get('encodingFormat') == 'mp3' else None, | |
36 | 'duration': parse_duration(video_data.get('duration')), | |
37 | 'title': self._html_search_regex(r'(?s)<h1[^>]*itemprop="[^"]*name[^"]*"[^>]*>(.+?)</h1>', | |
38 | webpage, 'title', default=self._og_search_title(webpage)), | |
4b3c5d1b | 39 | 'description': self._html_search_regex( |
d05460e5 | 40 | r'(?s)<meta name="description"\s*content="([^"]+)', webpage, 'description', default=None), |
4b3c5d1b B |
41 | 'thumbnail': self._og_search_thumbnail(webpage), |
42 | 'uploader': self._html_search_regex( | |
43 | r'(?s)<span class="author">(.*?)</span>', webpage, 'uploader', default=None), | |
d05460e5 AG |
44 | 'upload_date': unified_strdate(self._search_regex( |
45 | r'"datePublished"\s*:\s*"([^"]+)', webpage, 'timestamp', fatal=False)) | |
cce929ea | 46 | } |