]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/franceinter.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / franceinter.py
1 from .common import InfoExtractor
2 from ..utils import month_by_name
3
4
5 class FranceInterIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P<id>[^?#]+)'
7
8 _TEST = {
9 'url': 'https://www.franceinter.fr/emissions/affaires-sensibles/affaires-sensibles-07-septembre-2016',
10 'md5': '9e54d7bdb6fdc02a841007f8a975c094',
11 'info_dict': {
12 'id': 'affaires-sensibles/affaires-sensibles-07-septembre-2016',
13 'ext': 'mp3',
14 'title': 'Affaire Cahuzac : le contentieux du compte en Suisse',
15 'description': 'md5:401969c5d318c061f86bda1fa359292b',
16 'thumbnail': r're:^https?://.*\.jpg',
17 'upload_date': '20160907',
18 },
19 }
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23
24 webpage = self._download_webpage(url, video_id)
25
26 video_url = self._search_regex(
27 r'(?s)<div[^>]+class=["\']page-diffusion["\'][^>]*>.*?<button[^>]+data-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
28 webpage, 'video url', group='url')
29
30 title = self._og_search_title(webpage)
31 description = self._og_search_description(webpage)
32 thumbnail = self._html_search_meta(['og:image', 'twitter:image'], webpage)
33
34 upload_date_str = self._search_regex(
35 r'class=["\']\s*cover-emission-period\s*["\'][^>]*>[^<]+\s+(\d{1,2}\s+[^\s]+\s+\d{4})<',
36 webpage, 'upload date', fatal=False)
37 if upload_date_str:
38 upload_date_list = upload_date_str.split()
39 upload_date_list.reverse()
40 upload_date_list[1] = '%02d' % (month_by_name(upload_date_list[1], lang='fr') or 0)
41 upload_date_list[2] = '%02d' % int(upload_date_list[2])
42 upload_date = ''.join(upload_date_list)
43 else:
44 upload_date = None
45
46 return {
47 'id': video_id,
48 'title': title,
49 'description': description,
50 'thumbnail': thumbnail,
51 'upload_date': upload_date,
52 'formats': [{
53 'url': video_url,
54 'vcodec': 'none',
55 }],
56 }