Repository: yt-dlp/yt-dlp

Issue:
[ZDF] Fails to identify the best resolution
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.05.18** ([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/ytdl-org/youtube-dl#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)
- [X] 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

Europe

### Description

`yt-dlp -J https://www.zdf.de/serien/soko-stuttgart/das-geld-anderer-leute-100.html | python3 -m json.tool`
recommends https://rodlzdf-a.akamaihd.net/none/zdf/19/12/191205_1800_sendung_sok8/6/191205_1800_sendung_sok8_a1a2_1496k_p13v14.mp4
as the URL to download, which is 852x480. But it also correctly reports several options with 1280x720.

For the recommended option `http-h264_aac_mp4_http_na_na-veryhigh-3`, the resolution is not listed.

### Verbose log

```shell
[debug] Command-line config: ['-vU', '-J', 'https://www.zdf.de/serien/soko-stuttgart/das-geld-anderer-leute-100.html']
[debug] User config "/home/ritzert/.config/yt-dlp/config": ['--all-subs', '--convert-subs=srt', '-k', '--write-annotations', '--write-info-json', '--write-description', '--compat-options', 'filename']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8 (No ANSI), error utf-8, screen utf-8
[debug] yt-dlp version 2022.05.18 [b14d52355]
[debug] Compatibility options: filename
[debug] Python version 3.10.4 (CPython 64bit) - Linux-5.15.0-35-generic-x86_64-with-glibc2.35
[debug] Checking exe version: ffprobe -bsfs
[debug] Checking exe version: ffmpeg -bsfs
[debug] exe versions: ffmpeg 4.4.1 (setts), ffprobe 4.4.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.11.0, brotli-1.0.9, certifi-2020.06.20, mutagen-1.45.1, pyxattr-0.7.2, secretstorage-3.3.1, sqlite3-2.6.0, websockets-9.1
[debug] Proxy map: {}
Latest version: 2022.05.18, Current version: 2022.05.18
yt-dlp is up to date (2022.05.18)
[debug] Using fake IP 53.52.251.248 (DE) as X-Forwarded-For
[debug] [ZDF] Extracting URL: https://www.zdf.de/serien/soko-stuttgart/das-geld-anderer-leute-100.html
[ZDF] das-geld-anderer-leute-100: Downloading webpage
[ZDF] das-geld-anderer-leute-100: Downloading JSON content
[ZDF] das-geld-anderer-leute-100: Downloading JSON metadata
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[debug] Sort order given by extractor: hasaud, res, quality, language_preference
[debug] Formats sorted by: hasvid, ie_pref, hasaud, res, quality, lang, fps, hdr:12(7), vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, source, id
[debug] Downloading subtitles: deu
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 191205_1800_sendung_sok8: Downloading 1 format(s): http-h264_aac_mp4_http_na_na-veryhigh-3
```



Discussion:
I tried to attach the full JSON, but it's too long, so here are some excerpts:

```
        {
            "format_id": "hls-2641-0",
            "url": "https://zdfvod-rwrtr.akamaized.net/i/audiotrack=0:deu:Audiodeskription,1:deu:TV%20Ton,/mp4/none/zdf/19/12/191205_1800_sendung_sok8/6/191205_1800_sendung_sok8,_a3a4_476k_p9,_a1a2_476k_p9,_a3a4_776k_p11,_a3a4_1496k_p13,_a3a4_2296k_p14,_a3a4_3296k_p15,v14.mp4.csmil/index-f6-v1-a1.m3u8",
            "manifest_url": "https://zdfvod.akamaized.net/i/mp4/none/zdf/19/12/191205_1800_sendung_sok8/6/191205_1800_sendung_sok8,_a3a4_476k_p9,_a1a2_476k_p9,_a3a4_776k_p11,_a3a4_1496k_p13,_a3a4_2296k_p14,_a3a4_3296k_p15,v14.mp4.csmil/master.m3u8?audiotrack=0:deu:Audiodeskription,1:deu:TV%20Ton",
            "tbr": 2641.565,
            "ext": "mp4",
            "fps": 50.0,
            "protocol": "m3u8_native",
            "width": 1280,
            "height": 720,
            "abr": 0.0,
            "vcodec": "avc1.640028",
            "acodec": "none",
            "format_note": "auto, ad",
            "language": "deu",
            "language_preference": -10,
            "quality": 0,
            "video_ext": "mp4",
            "audio_ext": "none",
            "vbr": 2641.565,
            "format": "hls-2641-0 - 1280x720 (auto, ad)",
            "resolution": "1280x720",
            "dynamic_range": "SDR",
            "filesize_approx": 872688545.9200001,
            "http_headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36",
                "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                "Accept-Language": "en-us,en;q=0.5",
                "Sec-Fetch-Mode": "navigate",
                "X-Forwarded-For": "53.172.179.248"
            }
```

```
    "requested_downloads": [
        {
            "vcodec": "h264",
            "acodec": "aac",
            "url": "https://rodlzdf-a.akamaihd.net/none/zdf/19/12/191205_1800_sendung_sok8/6/191205_1800_sendung_sok8_a1a2_1496k_p13v14.mp4",
            "format_id": "http-h264_aac_mp4_http_na_na-veryhigh-3",
            "format_note": "veryhigh, main",
            "language": "deu",
            "language_preference": 10,
            "quality": 4,
            "protocol": "https",
            "ext": "mp4",
            "video_ext": "mp4",
            "audio_ext": "none",
            "format": "http-h264_aac_mp4_http_na_na-veryhigh-3 - unknown (veryhigh, main)",
            "dynamic_range": "SDR",
            "http_headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36",
                "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                "Accept-Language": "en-us,en;q=0.5",
                "Sec-Fetch-Mode": "navigate",
                "X-Forwarded-For": "53.172.179.248"
            },
            "epoch": 1654693439,
            "_filename": "Das Geld anderer Leute-191205_1800_sendung_sok8.mp4",
            "__write_download_archive": false
        }
    ],
```
The issue is that yt-dlp doesn't know the resolution of many of the formats
```
❯ yt-dlp -F https://www.zdf.de/serien/soko-stuttgart/das-geld-anderer-leute-100.html
[ZDF] das-geld-anderer-leute-100: Downloading webpage
[ZDF] das-geld-anderer-leute-100: Downloading JSON content
[ZDF] das-geld-anderer-leute-100: Downloading JSON metadata
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[ZDF] 191205_1800_sendung_sok8: Downloading m3u8 information
[info] Available formats for 191205_1800_sendung_sok8:
ID                                      EXT RESOLUTION FPS │   FILESIZE   TBR PROTO  │ VCODEC        VBR ACODEC     ABR MORE INFO
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
hls-audio0-Audiodeskription-0           mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] Audiodeskription
hls-audio0-TV_Ton-0                     mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] TV Ton
hls-audio0-Audiodeskription-1           mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] Audiodeskription
hls-audio0-TV_Ton-1                     mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] TV Ton
hls-audio0-Audiodeskription-2           mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] Audiodeskription
hls-audio0-TV_Ton-2                     mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] TV Ton
hls-audio0-Audiodeskription-3           mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] Audiodeskription
hls-audio0-TV_Ton-3                     mp4 audio only     │                  m3u8_n │ audio only        unknown        [de] TV Ton
hls-381-0                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] auto, ad
hls-381-1                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] auto, ad
hls-381-2                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] auto, main
hls-381-3                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] auto, main
hls-381-4                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] med, ad
hls-381-5                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] med, ad
hls-381-6                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] med, main
hls-381-7                               mp4 480x272     25 │ ~120.28MiB  381k m3u8_n │ avc1.4d401f  381k video only  0k [deu] med, main
hls-614-0                               mp4 640x360     25 │ ~193.56MiB  614k m3u8_n │ avc1.4d401f  614k video only  0k [deu] auto, ad
hls-614-1                               mp4 640x360     25 │ ~193.56MiB  614k m3u8_n │ avc1.4d401f  614k video only  0k [deu] auto, main
hls-614-2                               mp4 640x360     25 │ ~193.56MiB  614k m3u8_n │ avc1.4d401f  614k video only  0k [deu] med, ad
hls-614-3                               mp4 640x360     25 │ ~193.56MiB  614k m3u8_n │ avc1.4d401f  614k video only  0k [deu] med, main
hls-1181-0                              mp4 852x480     25 │ ~372.21MiB 1181k m3u8_n │ avc1.4d401f 1181k video only  0k [deu] auto, ad
hls-1181-1                              mp4 852x480     25 │ ~372.21MiB 1181k m3u8_n │ avc1.4d401f 1181k video only  0k [deu] auto, main
hls-1181-2                              mp4 852x480     25 │ ~372.21MiB 1181k m3u8_n │ avc1.4d401f 1181k video only  0k [deu] med, ad
hls-1181-3                              mp4 852x480     25 │ ~372.21MiB 1181k m3u8_n │ avc1.4d401f 1181k video only  0k [deu] med, main
hls-1827-0                              mp4 1024x576    25 │ ~575.84MiB 1827k m3u8_n │ avc1.4d401f 1827k video only  0k [deu] auto, ad
hls-1827-1                              mp4 1024x576    25 │ ~575.84MiB 1827k m3u8_n │ avc1.4d401f 1827k video only  0k [deu] auto, main
hls-2641-0                              mp4 1280x720    50 │ ~832.26MiB 2641k m3u8_n │ avc1.640028 2641k video only  0k [deu] auto, ad
hls-2641-1                              mp4 1280x720    50 │ ~832.26MiB 2641k m3u8_n │ avc1.640028 2641k video only  0k [deu] auto, main
http-h264_aac_mp4_http_na_na-low-0      mp4 unknown        │                  https  │ h264              aac            [deu] low, ad
http-h264_aac_mp4_http_na_na-low-1      mp4 unknown        │                  https  │ h264              aac            [deu] low, main
http-h264_aac_mp4_http_na_na-high-0     mp4 unknown        │                  https  │ h264              aac            [deu] high, ad
http-h264_aac_mp4_http_na_na-high-1     mp4 unknown        │                  https  │ h264              aac            [deu] high, ad
http-h264_aac_mp4_http_na_na-high-2     mp4 unknown        │                  https  │ h264              aac            [deu] high, main
http-h264_aac_mp4_http_na_na-high-3     mp4 unknown        │                  https  │ h264              aac            [deu] high, main
http-h264_aac_mp4_http_na_na-veryhigh-0 mp4 unknown        │                  https  │ h264              aac            [deu] veryhigh, ad
http-h264_aac_mp4_http_na_na-veryhigh-1 mp4 unknown        │                  https  │ h264              aac            [deu] veryhigh, ad
http-h264_aac_mp4_http_na_na-veryhigh-2 mp4 unknown        │                  https  │ h264              aac            [deu] veryhigh, main
http-h264_aac_mp4_http_na_na-veryhigh-3 mp4 unknown        │                  https  │ h264              aac            [deu] veryhigh, main
```

Resolving patch:
diff --git a/yt_dlp/extractor/zdf.py b/yt_dlp/extractor/zdf.py
--- a/yt_dlp/extractor/zdf.py
+++ b/yt_dlp/extractor/zdf.py
@@ -69,6 +69,7 @@ def _extract_format(self, video_id, formats, format_urls, meta):
             f.update({
                 'url': format_url,
                 'format_id': join_nonempty('http', meta.get('type'), meta.get('quality')),
+                'tbr': int_or_none(self._search_regex(r'_(\d+)k_', format_url, default=None))
             })
             new_formats = [f]
         formats.extend(merge_dicts(f, {
@@ -108,7 +109,7 @@ def _extract_ptmd(self, ptmd_url, video_id, api_token, referrer):
                                 'class': track.get('class'),
                                 'language': track.get('language'),
                             })
-        self._sort_formats(formats, ('hasaud', 'res', 'quality', 'language_preference'))
+        self._sort_formats(formats, ('tbr', 'res', 'quality', 'language_preference'))
 
         duration = float_or_none(try_get(
             ptmd, lambda x: x['attributes']['duration']['value']), scale=1000)
@@ -187,7 +188,7 @@ class ZDFIE(ZDFBaseIE):
         },
     }, {
         'url': 'https://www.zdf.de/funk/druck-11790/funk-alles-ist-verzaubert-102.html',
-        'md5': '3d6f1049e9682178a11c54b91f3dd065',
+        'md5': '57af4423db0455a3975d2dc4578536bc',
         'info_dict': {
             'ext': 'mp4',
             'id': 'video_funk_1770473',
@@ -230,6 +231,19 @@ class ZDFIE(ZDFBaseIE):
             'timestamp': 1641355200,
             'upload_date': '20220105',
         },
+        'skip': 'No longer available "Diese Seite wurde leider nicht gefunden"'
+    }, {
+        'url': 'https://www.zdf.de/serien/soko-stuttgart/das-geld-anderer-leute-100.html',
+        'info_dict': {
+            'id': '191205_1800_sendung_sok8',
+            'ext': 'mp4',
+            'title': 'Das Geld anderer Leute',
+            'description': 'md5:cb6f660850dc5eb7d1ab776ea094959d',
+            'duration': 2581.0,
+            'timestamp': 1654790700,
+            'upload_date': '20220609',
+            'thumbnail': 'https://epg-image.zdf.de/fotobase-webdelivery/images/e2d7e55a-09f0-424e-ac73-6cac4dd65f35?layout=2400x1350',
+        },
     }]
 
     def _extract_entry(self, url, player, content, video_id):


Test patch: