aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElyse <26639800+elyse0@users.noreply.github.com>2022-07-30 03:51:19 -0500
committerGitHub <noreply@github.com>2022-07-30 14:21:19 +0530
commitdb5f24820426323f797da206fa8fa1e5b5d7ffe1 (patch)
treeb71b8cbda0bf0c18650c3ce5da1593805a58e2b8
parent871a8929bcc3e8432d5341752dd888e057e5cfae (diff)
downloadhypervideo-pre-db5f24820426323f797da206fa8fa1e5b5d7ffe1.tar.lz
hypervideo-pre-db5f24820426323f797da206fa8fa1e5b5d7ffe1.tar.xz
hypervideo-pre-db5f24820426323f797da206fa8fa1e5b5d7ffe1.zip
[extractor/ina] Improve extractor (#4487)
Closes #4419 Authored by: elyse0
-rw-r--r--yt_dlp/extractor/ina.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/yt_dlp/extractor/ina.py b/yt_dlp/extractor/ina.py
index 9e2c9cf47..857013df3 100644
--- a/yt_dlp/extractor/ina.py
+++ b/yt_dlp/extractor/ina.py
@@ -3,7 +3,7 @@ from ..utils import unified_strdate
class InaIE(InfoExtractor):
- _VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:[^/]+/)?(?:video|audio)/(?P<id>\w+)'
+ _VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:[^?#]+/)(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://www.ina.fr/video/I12055569/francois-hollande-je-crois-que-c-est-clair-video.html',
'md5': 'c5a09e5cb5604ed10709f06e7a377dda',
@@ -11,7 +11,7 @@ class InaIE(InfoExtractor):
'id': 'I12055569',
'ext': 'mp4',
'title': 'François Hollande "Je crois que c\'est clair"',
- 'description': 'md5:08201f1c86fb250611f0ba415d21255a',
+ 'description': 'md5:19f61e2b4844ed4bb2e3df9ab9f527ff',
'upload_date': '20070712',
'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/3c4/I12055569.jpeg',
}
@@ -38,21 +38,42 @@ class InaIE(InfoExtractor):
'upload_date': '19821204',
'duration': 657,
'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/203/CPB8205116303.jpeg',
- }
+ },
+ }, {
+ 'url': 'https://www.ina.fr/ina-eclaire-actu/arletty-carriere-conseils-actrice-marcel-carne',
+ 'md5': '743d6f069a00e19dda0da166a54eeccb',
+ 'info_dict': {
+ 'id': 'I22203233',
+ 'ext': 'mp4',
+ 'title': 'Arletty sur le métier d\'actrice',
+ 'description': 'md5:3d89b5e419d8514c934f146045ccdbad',
+ 'upload_date': '19581128',
+ 'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/082/I22203233.jpeg',
+ },
+ }, {
+ 'url': 'https://www.ina.fr/ina-eclaire-actu/chasse-croise-sncf-gare-d-austerlitz-vacances-d-ete',
+ 'md5': 'a96fb85e9ba3b5c5b2eeb0c5daa55f2f',
+ 'info_dict': {
+ 'id': 'CAF91038285',
+ 'ext': 'mp4',
+ 'title': 'Les grands départs : les trains',
+ 'description': 'md5:1630ee819d8d4da97df53459e99f72bb',
+ 'upload_date': '19740801',
+ 'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/2cf/CAF91038285.jpeg',
+ },
}]
def _real_extract(self, url):
- video_id = self._match_id(url).upper()
- webpage = self._download_webpage(url, video_id)
+ display_id = self._match_id(url)
+ webpage = self._download_webpage(url, display_id)
- api_url = self._html_search_regex(
- r'asset-details-url\s*=\s*["\'](?P<api_url>[^"\']+)',
- webpage, 'api_url').replace(video_id, f'{video_id}.json')
+ api_url = self._html_search_regex(r'asset-details-url\s*=\s*["\'](?P<api_url>[^"\']+)', webpage, 'api_url')
+ asset_id = self._search_regex(r'assets/([^?/]+)', api_url, 'asset_id')
- api_response = self._download_json(api_url, video_id)
+ api_response = self._download_json(api_url.replace(asset_id, f'{asset_id}.json'), asset_id)
return {
- 'id': video_id,
+ 'id': asset_id,
'url': api_response['resourceUrl'],
'ext': {'video': 'mp4', 'audio': 'mp3'}.get(api_response.get('type')),
'title': api_response.get('title'),