Repository: yt-dlp/yt-dlp

Issue:
[hrfernsehen] Unable to extract ardloader
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.09.01** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [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 I'm willing to share it if required

### Region

Germany

### Provide a description that is worded well enough to be understood

Attempting to download the following video using the latest yt-dlp (2022.09.01) fails, with yt-dlp asking for a bug report to be submitted:

https://www.hessenschau.de/tv-sendung/hessischer-gruenderpreis--start-up-aus-kassel,video-173488.html

Please see below for the full verbose output from yt-dlp. Thanks for looking into this.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', 'https://www.hessenschau.de/tv-sendung/hessischer-gruenderpreis--start-up-aus-kassel,video-173488.html']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out cp1252 (No VT), error cp1252 (No VT), screen cp1252 (No VT)
[debug] yt-dlp version 2022.09.01 [5d7c7d6] (win32_exe)
[debug] Python 3.8.10 (CPython 64bit)
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg N-107213-gfed07efcde-20220622 (setts), ffprobe N-107213-gfed07efcde-20220622
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Loaded 1670 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.09.01, Current version: 2022.09.01
yt-dlp is up to date (2022.09.01)
[debug] Using fake IP 53.149.240.105 (DE) as X-Forwarded-For
[debug] [hrfernsehen] Extracting URL: https://www.hessenschau.de/tv-sendung/hessischer-gruenderpreis--start-up-aus-kassel,video-173488.html
[hrfernsehen] 173488: Downloading webpage
ERROR: [hrfernsehen] 173488: Unable to extract ardloader; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "yt_dlp\extractor\common.py", line 670, in extract
  File "yt_dlp\extractor\hrfensehen.py", line 75, in _real_extract
  File "yt_dlp\extractor\common.py", line 1222, in _search_regex
```



Discussion:
For devs:
The loader name appears to have changed back to `data-hr-mediaplayer-loader` from what was changed in https://github.com/yt-dlp/yt-dlp/pull/2217. Maybe support both just to be safe (`data-(?:new-)?hr-mediaplayer-loader='([^']*)`?).

After that the JSON payload structure of loader_data has changed completely, so the extractor will need to be updated for that. There is some more metadata in the loader_data that could be extracted too, such as thumbnails, duration.
would love to take this up :)


Resolving patch:
diff --git a/yt_dlp/extractor/hrfensehen.py b/yt_dlp/extractor/hrfensehen.py
--- a/yt_dlp/extractor/hrfensehen.py
+++ b/yt_dlp/extractor/hrfensehen.py
@@ -1,14 +1,19 @@
 import json
 import re
 
-from ..utils import int_or_none, unified_timestamp, unescapeHTML
+from ..utils import (
+    int_or_none,
+    traverse_obj,
+    try_call,
+    unescapeHTML,
+    unified_timestamp,
+)
 from .common import InfoExtractor
 
 
 class HRFernsehenIE(InfoExtractor):
     IE_NAME = 'hrfernsehen'
     _VALID_URL = r'^https?://www\.(?:hr-fernsehen|hessenschau)\.de/.*,video-(?P<id>[0-9]{6})\.html'
-
     _TESTS = [{
         'url': 'https://www.hessenschau.de/tv-sendung/hessenschau-vom-26082020,video-130546.html',
         'md5': '5c4e0ba94677c516a2f65a84110fc536',
@@ -21,10 +26,11 @@ class HRFernsehenIE(InfoExtractor):
             'subtitles': {'de': [{
                 'url': 'https://hr-a.akamaihd.net/video/as/hessenschau/2020_08/hrLogo_200826200407_L385592_512x288-25p-500kbit.vtt'
             }]},
-            'timestamp': 1598470200,
+            'timestamp': 1598400000,
             'upload_date': '20200826',
-            'thumbnail': 'https://www.hessenschau.de/tv-sendung/hs_ganz-1554~_t-1598465545029_v-16to9__medium.jpg',
-            'title': 'hessenschau vom 26.08.2020'
+            'thumbnail': 'https://www.hessenschau.de/tv-sendung/hs_ganz-1554~_t-1598465545029_v-16to9.jpg',
+            'title': 'hessenschau vom 26.08.2020',
+            'duration': 1654
         }
     }, {
         'url': 'https://www.hr-fernsehen.de/sendungen-a-z/mex/sendungen/fair-und-gut---was-hinter-aldis-eigenem-guetesiegel-steckt,video-130544.html',
@@ -33,25 +39,18 @@ class HRFernsehenIE(InfoExtractor):
 
     _GEO_COUNTRIES = ['DE']
 
-    def extract_airdate(self, loader_data):
-        airdate_str = loader_data.get('mediaMetadata', {}).get('agf', {}).get('airdate')
-
-        if airdate_str is None:
-            return None
-
-        return unified_timestamp(airdate_str)
-
     def extract_formats(self, loader_data):
         stream_formats = []
-        for stream_obj in loader_data["videoResolutionLevels"]:
+        data = loader_data['mediaCollection']['streams'][0]['media']
+        for inner in data[1:]:
             stream_format = {
-                'format_id': str(stream_obj['verticalResolution']) + "p",
-                'height': stream_obj['verticalResolution'],
-                'url': stream_obj['url'],
+                'format_id': try_call(lambda: f'{inner["maxHResolutionPx"]}p'),
+                'height': inner.get('maxHResolutionPx'),
+                'url': inner['url'],
             }
 
             quality_information = re.search(r'([0-9]{3,4})x([0-9]{3,4})-([0-9]{2})p-([0-9]{3,4})kbit',
-                                            stream_obj['url'])
+                                            inner['url'])
             if quality_information:
                 stream_format['width'] = int_or_none(quality_information.group(1))
                 stream_format['height'] = int_or_none(quality_information.group(2))
@@ -72,22 +71,22 @@ def _real_extract(self, url):
         description = self._html_search_meta(
             ['description'], webpage)
 
-        loader_str = unescapeHTML(self._search_regex(r"data-new-hr-mediaplayer-loader='([^']*)'", webpage, "ardloader"))
+        loader_str = unescapeHTML(self._search_regex(r"data-(?:new-)?hr-mediaplayer-loader='([^']*)'", webpage, 'ardloader'))
         loader_data = json.loads(loader_str)
 
+        subtitle = traverse_obj(loader_data, ('mediaCollection', 'subTitles', 0, 'sources', 0, 'url'))
+
         info = {
             'id': video_id,
             'title': title,
             'description': description,
             'formats': self.extract_formats(loader_data),
-            'timestamp': self.extract_airdate(loader_data)
+            'subtitles': {'de': [{'url': subtitle}]},
+            'timestamp': unified_timestamp(self._search_regex(
+                r'<time\sdatetime="(\d{4}\W\d{1,2}\W\d{1,2})', webpage, 'datetime', fatal=False)),
+            'duration': int_or_none(traverse_obj(
+                loader_data, ('playerConfig', 'pluginData', 'trackingAti@all', 'richMedia', 'duration'))),
+            'thumbnail': self._search_regex(r'thumbnailUrl\W*([^"]+)', webpage, 'thumbnail', default=None),
         }
 
-        if "subtitle" in loader_data:
-            info["subtitles"] = {"de": [{"url": loader_data["subtitle"]}]}
-
-        thumbnails = list(set([t for t in loader_data.get("previewImageUrl", {}).values()]))
-        if len(thumbnails) > 0:
-            info["thumbnails"] = [{"url": t} for t in thumbnails]
-
         return info


Test patch: