Repository: yt-dlp/yt-dlp

Issue:
Can't extract from sportdeutschland.tv
### Checklist

- [X] I'm reporting a site feature request
- [X] I've verified that I'm running yt-dlp version **2022.03.08.1**. ([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 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

Germany

### Example URLs

https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0

### Description

Can't extract from this link:

https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0

### Verbose log

```shell
[debug] Command-line config: ['-vU', 'https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0', '--verbose']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8 (No ANSI), err utf-8 (No ANSI), pref cp1252
[debug] yt-dlp version 2022.03.08.1 [c0c2c57] (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 2022-01-10-git-f37e66b393-full_build-www.gyan.dev (setts), ffprobe 2022-01-10-git-f37e66b393-full_build-www.gyan.dev
[debug] Optional libraries: brotli, Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.03.08.1, Current version: 2022.03.08.1
yt-dlp is up to date (2022.03.08.1)
[debug] [SportDeutschland] Extracting URL: https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0
[SportDeutschland] deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0: Downloading JSON metadata
Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 735, in _request_webpage
  File "yt_dlp\YoutubeDL.py", line 3591, in urlopen
  File "urllib\request.py", line 531, in open
  File "urllib\request.py", line 640, in http_response
  File "urllib\request.py", line 569, in error
  File "urllib\request.py", line 502, in _call_chain
  File "urllib\request.py", line 649, in http_error_default
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 617, in extract
  File "yt_dlp\extractor\sportdeutschland.py", line 47, in _real_extract
  File "yt_dlp\extractor\common.py", line 997, in _download_json
  File "yt_dlp\extractor\common.py", line 976, in _download_json_handle
  File "yt_dlp\extractor\common.py", line 768, in _download_webpage_handle
  File "yt_dlp\extractor\common.py", line 753, in _request_webpage
yt_dlp.utils.ExtractorError: Unable to download JSON metadata: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); please report this issue on https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template
properly. Confirm you are on the latest version using  yt-dlp -U

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1389, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1459, in __extract_info
  File "yt_dlp\extractor\common.py", line 643, in extract
yt_dlp.utils.ExtractorError: [SportDeutschland] deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0: Unable to download JSON metadata: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using  yt-dlp -U

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\__main__.py", line 19, in <module>
  File "yt_dlp\__init__.py", line 864, in main
  File "yt_dlp\__init__.py", line 854, in _real_main
  File "yt_dlp\YoutubeDL.py", line 3254, in download
  File "yt_dlp\YoutubeDL.py", line 3227, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1380, in extract_info
  File "yt_dlp\YoutubeDL.py", line 1407, in wrapper
  File "yt_dlp\utils.py", line 1088, in format_traceback
TypeError: format_exception() missing 2 required positional arguments: 'value' and 'tb'
[31380] Failed to execute script '__main__' due to unhandled exception!
```



Discussion:
I think the api url changed. At my computer, the website give geo-block warning but the video is playing even without VPN.
I got the api url in https://api.sportdeutschland.tv/api/stateless/frontend/assets/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0. In there, we can get video (likely the OP want, not sure though) from `[video][0][src]`.
In the context of the OP url, the media url i found is https://chess.dosbnewmedia.de//mediafiles/89052def9adf41c9b910a6abd23d7adb.smil

Here's the log of yt-dlp when this url given as input:
```
~\test_download>yt-dlp -v "https://chess.dosbnewmedia.de//mediafiles/89052def9adf41c9b910a6abd23d7adb.smil" --no-check-certificate --downloader native
[debug] Command-line config: ['-v', 'https://chess.dosbnewmedia.de//mediafiles/89052def9adf41c9b910a6abd23d7adb.smil', '--no-check-certificate', '--downloader', 'native']
[debug] Portable config "~\yt-dlp\yt-dlp.conf": ['-v', '--netrc-location', '~yt-dlp.netrc', '-f', 'bv+ba/b', '--compat-options', 'format-sort', '--embed-metadata', '--embed-subs', '--sub-langs', 'all', '--console-title', '--downloader', 'aria2c']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.06.29 [9d339c4] (win32_exe)
[debug] Compatibility options: format-sort
[debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.19044-SP0
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 5.0.1-full_build-www.gyan.dev (setts), ffprobe 5.0.1-full_build-www.gyan.dev
[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] [generic] Extracting URL: https://chess.dosbnewmedia.de//mediafiles/89052def9adf41c9b910a6abd23d7adb.smil
[generic] 89052def9adf41c9b910a6abd23d7adb: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 89052def9adf41c9b910a6abd23d7adb: Downloading webpage
[generic] 89052def9adf41c9b910a6abd23d7adb: Extracting information
[generic] 89052def9adf41c9b910a6abd23d7adb: Downloading m3u8 information
[debug] Identified a SMIL file
[debug] Sort order given by user: hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id
[debug] Formats sorted by: hasvid, ie_pref, hasaud, lang, quality, tbr, filesize, vbr, height, width, proto, vext, abr, aext, fps, fs_approx, source, id, res, hdr:12(7), vcodec:vp9.2(10), acodec, asr
[info] 89052def9adf41c9b910a6abd23d7adb: Downloading 1 format(s): hls-1
[debug] Invoking hlsnative downloader on "https://cloudvodstreamer4.dosbnewmedia.de/newhls/148054.json/index-v1-a1.m3u8"
[hlsnative] Downloading m3u8 manifest
WARNING: Live HLS streams are not supported by the native downloader. If this is a livestream, please add "--downloader ffmpeg --hls-use-mpegts" to your command
[hlsnative] Total fragments: 4110
[download] Destination: 89052def9adf41c9b910a6abd23d7adb [89052def9adf41c9b910a6abd23d7adb].mp4
[debug] File locking is not supported. Proceeding without locking
[download]   0.0% of ~27.63GiB at  742.02KiB/s ETA 10:49:37 (frag 1/4110)
ERROR: Interrupted by user
```
I don't download this file on my computer though, but when i tried play it in ffplay or mpv, it works, so i assume it would be the same as yt-dlp

Resolving patch:
diff --git a/yt_dlp/extractor/sportdeutschland.py b/yt_dlp/extractor/sportdeutschland.py
--- a/yt_dlp/extractor/sportdeutschland.py
+++ b/yt_dlp/extractor/sportdeutschland.py
@@ -1,95 +1,110 @@
 from .common import InfoExtractor
+
 from ..utils import (
-    clean_html,
-    float_or_none,
-    int_or_none,
-    parse_iso8601,
-    parse_qs,
-    strip_or_none,
-    try_get,
+    format_field,
+    traverse_obj,
+    unified_timestamp,
+    strip_or_none
 )
 
 
 class SportDeutschlandIE(InfoExtractor):
     _VALID_URL = r'https?://sportdeutschland\.tv/(?P<id>(?:[^/]+/)?[^?#/&]+)'
     _TESTS = [{
-        'url': 'https://sportdeutschland.tv/badminton/re-live-deutsche-meisterschaften-2020-halbfinals?playlistId=0',
+        'url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport/buchholzer-formationswochenende-2023-samstag-1-bundesliga-landesliga',
         'info_dict': {
-            'id': '5318cac0275701382770543d7edaf0a0',
+            'id': '983758e9-5829-454d-a3cf-eb27bccc3c94',
             'ext': 'mp4',
-            'title': 'Re-live: Deutsche Meisterschaften 2020 - Halbfinals - Teil 1',
-            'duration': 16106.36,
-        },
-        'params': {
-            'noplaylist': True,
-            # m3u8 download
-            'skip_download': True,
-        },
+            'title': 'Buchholzer Formationswochenende 2023 - Samstag - 1. Bundesliga / Landesliga',
+            'description': 'md5:a288c794a5ee69e200d8f12982f81a87',
+            'live_status': 'was_live',
+            'channel': 'Blau-Weiss Buchholz Tanzsport',
+            'channel_url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport',
+            'channel_id': '93ec33c9-48be-43b6-b404-e016b64fdfa3',
+            'display_id': '9839a5c7-0dbb-48a8-ab63-3b408adc7b54',
+            'duration': 32447,
+            'upload_date': '20230114',
+            'timestamp': 1673730018.0,
+        }
     }, {
-        'url': 'https://sportdeutschland.tv/badminton/re-live-deutsche-meisterschaften-2020-halbfinals?playlistId=0',
+        'url': 'https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0',
         'info_dict': {
-            'id': 'c6e2fdd01f63013854c47054d2ab776f',
-            'title': 'Re-live: Deutsche Meisterschaften 2020 - Halbfinals',
-            'description': 'md5:5263ff4c31c04bb780c9f91130b48530',
-            'duration': 31397,
-        },
-        'playlist_count': 2,
-    }, {
-        'url': 'https://sportdeutschland.tv/freeride-world-tour-2021-fieberbrunn-oesterreich',
-        'only_matching': True,
+            'id': '95b97d9a-04f6-4880-9039-182985c33943',
+            'ext': 'mp4',
+            'title': 'BWF Tour: 1. Runde Feld 1 - YONEX GAINWARD German Open 2022',
+            'description': 'md5:2afb5996ceb9ac0b2ac81f563d3a883e',
+            'live_status': 'was_live',
+            'channel': 'Deutscher Badminton Verband',
+            'channel_url': 'https://sportdeutschland.tv/deutscherbadmintonverband',
+            'channel_id': '93ca5866-2551-49fc-8424-6db35af58920',
+            'display_id': '95c80c52-6b9a-4ae9-9197-984145adfced',
+            'duration': 41097,
+            'upload_date': '20220309',
+            'timestamp': 1646860727.0,
+        }
     }]
 
     def _real_extract(self, url):
         display_id = self._match_id(url)
-        data = self._download_json(
-            'https://backend.sportdeutschland.tv/api/permalinks/' + display_id,
+        meta = self._download_json(
+            'https://api.sportdeutschland.tv/api/stateless/frontend/assets/' + display_id,
             display_id, query={'access_token': 'true'})
-        asset = data['asset']
-        title = (asset.get('title') or asset['label']).strip()
-        asset_id = asset.get('id') or asset.get('uuid')
+
+        asset_id = traverse_obj(meta, 'id', 'uuid')
+
         info = {
             'id': asset_id,
-            'title': title,
-            'description': clean_html(asset.get('body') or asset.get('description')) or asset.get('teaser'),
-            'duration': int_or_none(asset.get('seconds')),
+            'channel_url': format_field(meta, ('profile', 'slug'), 'https://sportdeutschland.tv/%s'),
+            **traverse_obj(meta, {
+                'title': (('title', 'name'), {strip_or_none}),
+                'description': 'description',
+                'channel': ('profile', 'name'),
+                'channel_id': ('profile', 'id'),
+                'is_live': 'currently_live',
+                'was_live': 'was_live'
+            }, get_all=False)
         }
-        videos = asset.get('videos') or []
+
+        videos = meta.get('videos') or []
+
         if len(videos) > 1:
-            playlist_id = parse_qs(url).get('playlistId', [None])[0]
-            if not self._yes_playlist(playlist_id, asset_id):
-                videos = [videos[int(playlist_id)]]
-
-            def entries():
-                for i, video in enumerate(videos, 1):
-                    video_id = video.get('uuid')
-                    video_url = video.get('url')
-                    if not (video_id and video_url):
-                        continue
-                    formats = self._extract_m3u8_formats(
-                        video_url.replace('.smil', '.m3u8'), video_id, 'mp4', fatal=False)
-                    if not formats and not self.get_param('ignore_no_formats'):
-                        continue
-                    yield {
-                        'id': video_id,
-                        'formats': formats,
-                        'title': title + ' - ' + (video.get('label') or 'Teil %d' % i),
-                        'duration': float_or_none(video.get('duration')),
-                    }
             info.update({
                 '_type': 'multi_video',
-                'entries': entries(),
-            })
-        else:
-            formats = self._extract_m3u8_formats(
-                videos[0]['url'].replace('.smil', '.m3u8'), asset_id, 'mp4')
-            section_title = strip_or_none(try_get(data, lambda x: x['section']['title']))
-            info.update({
-                'formats': formats,
-                'display_id': asset.get('permalink'),
-                'thumbnail': try_get(asset, lambda x: x['images'][0]),
-                'categories': [section_title] if section_title else None,
-                'view_count': int_or_none(asset.get('views')),
-                'is_live': asset.get('is_live') is True,
-                'timestamp': parse_iso8601(asset.get('date') or asset.get('published_at')),
-            })
+                'entries': self.processVideoOrStream(asset_id, video)
+            } for video in enumerate(videos) if video.get('formats'))
+
+        elif len(videos) == 1:
+            info.update(
+                self.processVideoOrStream(asset_id, videos[0])
+            )
+
+        livestream = meta.get('livestream')
+
+        if livestream is not None:
+            info.update(
+                self.processVideoOrStream(asset_id, livestream)
+            )
+
         return info
+
+    def process_video_or_stream(self, asset_id, video):
+        video_id = video['id']
+        video_src = video['src']
+        video_type = video['type']
+
+        token = self._download_json(
+            f'https://api.sportdeutschland.tv/api/frontend/asset-token/{asset_id}',
+            video_id, query={'type': video_type, 'playback_id': video_src})['token']
+        formats = self._extract_m3u8_formats(f'https://stream.mux.com/{video_src}.m3u8?token={token}', video_id)
+
+        video_data = {
+            'display_id': video_id,
+            'formats': formats,
+        }
+        if video_type == 'mux_vod':
+            video_data.update({
+                'duration': video.get('duration'),
+                'timestamp': unified_timestamp(video.get('created_at'))
+            })
+
+        return video_data


Test patch: