]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/ina.py
[extractor] Fix bug in 617f658b7ec1193749848c1b7343acab125dbc46
[yt-dlp.git] / yt_dlp / extractor / ina.py
CommitLineData
9fe4de34 1from .common import InfoExtractor
79c31893 2from ..utils import unified_strdate
9fe4de34
PH
3
4
5class InaIE(InfoExtractor):
79c31893 6 _VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:[^/]+/)?(?:video|audio)/(?P<id>\w+)'
b27a71e6 7 _TESTS = [{
79c31893
E
8 'url': 'https://www.ina.fr/video/I12055569/francois-hollande-je-crois-que-c-est-clair-video.html',
9 'md5': 'c5a09e5cb5604ed10709f06e7a377dda',
de563c9d
JMF
10 'info_dict': {
11 'id': 'I12055569',
12 'ext': 'mp4',
13 'title': 'François Hollande "Je crois que c\'est clair"',
79c31893
E
14 'description': 'md5:08201f1c86fb250611f0ba415d21255a',
15 'upload_date': '20070712',
16 'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/3c4/I12055569.jpeg',
6f5ac90c 17 }
b27a71e6
RA
18 }, {
19 'url': 'https://www.ina.fr/video/S806544_001/don-d-organes-des-avancees-mais-d-importants-besoins-video.html',
20 'only_matching': True,
c4c88869
RA
21 }, {
22 'url': 'https://www.ina.fr/audio/P16173408',
23 'only_matching': True,
24 }, {
25 'url': 'https://www.ina.fr/video/P16173408-video.html',
26 'only_matching': True,
9b664dc4 27 }, {
28 'url': 'http://m.ina.fr/video/I12055569',
29 'only_matching': True,
79c31893
E
30 }, {
31 'url': 'https://www.ina.fr/ina-eclaire-actu/video/cpb8205116303/les-jeux-electroniques',
32 'md5': '4b8284a9a3a184fdc7e744225b8251e7',
33 'info_dict': {
34 'id': 'CPB8205116303',
35 'ext': 'mp4',
36 'title': 'Les jeux électroniques',
37 'description': 'md5:e09f7683dad1cc60b74950490127d233',
38 'upload_date': '19821204',
39 'duration': 657,
40 'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/203/CPB8205116303.jpeg',
41 }
b27a71e6 42 }]
9fe4de34 43
de563c9d 44 def _real_extract(self, url):
79c31893
E
45 video_id = self._match_id(url).upper()
46 webpage = self._download_webpage(url, video_id)
9fe4de34 47
79c31893
E
48 api_url = self._html_search_regex(
49 r'asset-details-url\s*=\s*["\'](?P<api_url>[^"\']+)',
50 webpage, 'api_url').replace(video_id, f'{video_id}.json')
9fe4de34 51
79c31893 52 api_response = self._download_json(api_url, video_id)
9fe4de34 53
de563c9d
JMF
54 return {
55 'id': video_id,
79c31893
E
56 'url': api_response['resourceUrl'],
57 'ext': {'video': 'mp4', 'audio': 'mp3'}.get(api_response.get('type')),
58 'title': api_response.get('title'),
59 'description': api_response.get('description'),
60 'upload_date': unified_strdate(api_response.get('dateOfBroadcast')),
61 'duration': api_response.get('duration'),
62 'thumbnail': api_response.get('resourceThumbnail'),
de563c9d 63 }