Repository: yt-dlp/yt-dlp

Issue:
Site support request: ina.fr
### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I'm running yt-dlp version **2022.01.21**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that none of provided URLs [violate any copyrights](https://github.com/ytdl-org/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and am willing to share it if required

### Region

Brazil and France at least

### Example URLs

- Single video: https://www.ina.fr/ina-eclaire-actu/1982-la-mode-du-jeu-electronique-deferle-sur-la-france
Same video, different link: https://www.ina.fr/ina-eclaire-actu/video/cpb8205116303/les-jeux-electroniques

- Single video: https://www.ina.fr/ina-eclaire-actu/l-alphabet-grec-24-lettres-presque-autant-de-siecles-d-histoire
Same video, different link: https://www.ina.fr/ina-eclaire-actu/video/i21333172/georges-et-claude-d-athenes-deux-enfants-parmi-tant-d-autres

### Description

- The National Audiovisual Institute of France
INA is a public institution founded in 1975 with the aim of archiving French audiovisual heritage, creating content, researching, and transferring knowledge in the audiovisual and digital fields.

### Verbose log

```shell
$ yt-dlp -vU https://www.ina.fr/ina-eclaire-actu/1982-la-mode-du-jeu-electronique-deferle-sur-la-france
[debug] Command-line config: ['-vU', 'https://www.ina.fr/ina-eclaire-actu/1982-la-mode-du-jeu-electronique-deferle-sur-la-france']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.01.21 [f20d607b0]
[debug] Python version 3.9.2 (CPython 64bit) - Linux-5.10.0-11-amd64-x86_64-with-glibc2.31
[debug] exe versions: ffmpeg 4.3.3-0, ffprobe 4.3.3-0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.01.21, Current version: 2022.01.21
yt-dlp is up to date (2022.01.21)
[debug] [generic] Extracting URL: https://www.ina.fr/ina-eclaire-actu/1982-la-mode-du-jeu-electronique-deferle-sur-la-france
[generic] 1982-la-mode-du-jeu-electronique-deferle-sur-la-france: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 1982-la-mode-du-jeu-electronique-deferle-sur-la-france: Downloading webpage
[generic] 1982-la-mode-du-jeu-electronique-deferle-sur-la-france: Extracting information
[debug] Looking for video embeds
[debug] Identified a video file
[debug] Default format spec: bestvideo*+bestaudio/best
[info] https://www.ina.fr/ina-eclaire-actu/1982-la-mode-du-jeu-electronique-deferle-sur-la-france: Downloading 1 format(s): 0
[debug] Invoking downloader on "https://www.ina.fr/ina-eclaire-actu/https%3A%2F%2Fwww.ina.fr%2Fina-eclaire-actu%2F1982-la-mode-du-jeu-electronique-deferle-sur-la-france"
ERROR: unable to download video data: HTTP Error 404: Not Found
Traceback (most recent call last):
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 3054, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 2769, in dl
    return fd.download(name, new_info, subtitle)
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/downloader/common.py", line 440, in download
    ret = self.real_download(filename, info_dict)
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/downloader/http.py", line 371, in real_download
    establish_connection()
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/downloader/http.py", line 119, in establish_connection
    raise err
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/downloader/http.py", line 113, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/home/mateus/.local/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 3526, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/ina.py b/yt_dlp/extractor/ina.py
--- a/yt_dlp/extractor/ina.py
+++ b/yt_dlp/extractor/ina.py
@@ -1,23 +1,19 @@
 from .common import InfoExtractor
-from ..utils import (
-    determine_ext,
-    int_or_none,
-    strip_or_none,
-    xpath_attr,
-    xpath_text,
-)
+from ..utils import unified_strdate
 
 
 class InaIE(InfoExtractor):
-    _VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:video|audio)/(?P<id>[A-Z0-9_]+)'
+    _VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:[^/]+/)?(?:video|audio)/(?P<id>\w+)'
     _TESTS = [{
-        'url': 'http://www.ina.fr/video/I12055569/francois-hollande-je-crois-que-c-est-clair-video.html',
-        'md5': 'a667021bf2b41f8dc6049479d9bb38a3',
+        'url': 'https://www.ina.fr/video/I12055569/francois-hollande-je-crois-que-c-est-clair-video.html',
+        'md5': 'c5a09e5cb5604ed10709f06e7a377dda',
         'info_dict': {
             'id': 'I12055569',
             'ext': 'mp4',
             'title': 'François Hollande "Je crois que c\'est clair"',
-            'description': 'md5:3f09eb072a06cb286b8f7e4f77109663',
+            'description': 'md5:08201f1c86fb250611f0ba415d21255a',
+            'upload_date': '20070712',
+            'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/3c4/I12055569.jpeg',
         }
     }, {
         'url': 'https://www.ina.fr/video/S806544_001/don-d-organes-des-avancees-mais-d-importants-besoins-video.html',
@@ -31,53 +27,37 @@ class InaIE(InfoExtractor):
     }, {
         'url': 'http://m.ina.fr/video/I12055569',
         'only_matching': True,
+    }, {
+        'url': 'https://www.ina.fr/ina-eclaire-actu/video/cpb8205116303/les-jeux-electroniques',
+        'md5': '4b8284a9a3a184fdc7e744225b8251e7',
+        'info_dict': {
+            'id': 'CPB8205116303',
+            'ext': 'mp4',
+            'title': 'Les jeux électroniques',
+            'description': 'md5:e09f7683dad1cc60b74950490127d233',
+            'upload_date': '19821204',
+            'duration': 657,
+            'thumbnail': 'https://cdn-hub.ina.fr/notice/690x517/203/CPB8205116303.jpeg',
+        }
     }]
 
     def _real_extract(self, url):
-        video_id = self._match_id(url)
-        info_doc = self._download_xml(
-            'http://player.ina.fr/notices/%s.mrss' % video_id, video_id)
-        item = info_doc.find('channel/item')
-        title = xpath_text(item, 'title', fatal=True)
-        media_ns_xpath = lambda x: self._xpath_ns(x, 'http://search.yahoo.com/mrss/')
-        content = item.find(media_ns_xpath('content'))
+        video_id = self._match_id(url).upper()
+        webpage = self._download_webpage(url, video_id)
 
-        get_furl = lambda x: xpath_attr(content, media_ns_xpath(x), 'url')
-        formats = []
-        for q, w, h in (('bq', 400, 300), ('mq', 512, 384), ('hq', 768, 576)):
-            q_url = get_furl(q)
-            if not q_url:
-                continue
-            formats.append({
-                'format_id': q,
-                'url': q_url,
-                'width': w,
-                'height': h,
-            })
-        if not formats:
-            furl = get_furl('player') or content.attrib['url']
-            ext = determine_ext(furl)
-            formats = [{
-                'url': furl,
-                'vcodec': 'none' if ext == 'mp3' else None,
-                'ext': ext,
-            }]
+        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')
 
-        thumbnails = []
-        for thumbnail in content.findall(media_ns_xpath('thumbnail')):
-            thumbnail_url = thumbnail.get('url')
-            if not thumbnail_url:
-                continue
-            thumbnails.append({
-                'url': thumbnail_url,
-                'height': int_or_none(thumbnail.get('height')),
-                'width': int_or_none(thumbnail.get('width')),
-            })
+        api_response = self._download_json(api_url, video_id)
 
         return {
             'id': video_id,
-            'formats': formats,
-            'title': title,
-            'description': strip_or_none(xpath_text(item, 'description')),
-            'thumbnails': thumbnails,
+            'url': api_response['resourceUrl'],
+            'ext': {'video': 'mp4', 'audio': 'mp3'}.get(api_response.get('type')),
+            'title': api_response.get('title'),
+            'description': api_response.get('description'),
+            'upload_date': unified_strdate(api_response.get('dateOfBroadcast')),
+            'duration': api_response.get('duration'),
+            'thumbnail': api_response.get('resourceThumbnail'),
         }


Test patch: