From 38a5fb16d142bcd8f051af003f8e1fd0c7078620 Mon Sep 17 00:00:00 2001 From: 0xvd <199783523+0xvd@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:33:22 +0530 Subject: [PATCH] [ie/servus] Fix extractor (#17768) Closes #16639 Authored by: 0xvd --- yt_dlp/extractor/servus.py | 53 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/yt_dlp/extractor/servus.py b/yt_dlp/extractor/servus.py index 841c7ebf33..8cdb09948c 100644 --- a/yt_dlp/extractor/servus.py +++ b/yt_dlp/extractor/servus.py @@ -1,13 +1,14 @@ from .common import InfoExtractor from ..utils import ( ExtractorError, + clean_html, float_or_none, format_field, int_or_none, - join_nonempty, + merge_dicts, traverse_obj, - unescapeHTML, unified_timestamp, + url_or_none, ) @@ -16,7 +17,7 @@ class ServusIE(InfoExtractor): https?:// (?:www\.)? (?: - servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)| + servus(?:tv)?\.com/(?:(?:at|de)/p(?:age)?/?[^/]+|tv/videos)?| (?:servustv|pm-wissen)\.com/(?:[^/]+/)?v(?:ideos)? ) /(?P[aA]{2}-?\w+|\d+-\d+) @@ -27,10 +28,10 @@ class ServusIE(InfoExtractor): 'info_dict': { 'id': 'AA-28BYCQNH92111', 'ext': 'mp4', - 'title': 'Vie Ferrate - Klettersteige in den Alpen', - 'description': 'md5:25e47ddd83a009a0f9789ba18f2850ce', - 'thumbnail': r're:^https?://.*\.jpg', - 'duration': 2823, + 'title': 'Klettersteige in den Alpen', + 'description': 'md5:86d0c9eb3b2b6d7cdff247d1ba997ace', + 'thumbnail': r're:^https?://.*', + 'duration': 2823280.0, 'timestamp': 1655752333, 'upload_date': '20220620', 'series': 'Bergwelten', @@ -38,7 +39,6 @@ class ServusIE(InfoExtractor): 'season_number': 11, 'episode': 'Episode 8 - Vie Ferrate – Klettersteige in den Alpen', 'episode_number': 8, - 'categories': ['Bergwelten'], }, 'params': {'skip_download': 'm3u8'}, }, { @@ -71,13 +71,15 @@ class ServusIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url).upper() - - webpage = self._download_webpage(url, video_id) - next_data = self._search_nextjs_data(webpage, video_id, fatal=False) - + webpage, urlh = self._download_webpage_handle(url, video_id) + video_id = self._match_id(urlh.url).upper() + next_data = {} + next_data = merge_dicts(*traverse_obj( + self._search_nextjs_v13_data(webpage, video_id, fatal=False), + (..., 'featuredCollectionCards', lambda _, v: video_id == v['id']))) video = self._download_json( - 'https://api-player.redbull.com/stv/servus-tv-playnet', - video_id, 'Downloading video JSON', query={'videoId': video_id}) + 'https://api-player.redbull.com/tv', video_id, 'Downloading video JSON', + query={'videoId': video_id, 'tenant': 'stv', 'locale': 'de'}) if not video.get('videoUrl'): self._report_errors(video) formats, subtitles = self._extract_m3u8_formats_and_subtitles( @@ -93,8 +95,8 @@ class ServusIE(InfoExtractor): return { 'id': video_id, 'title': video.get('title'), - 'description': self._get_description(next_data) or video.get('description'), - 'thumbnail': video.get('poster'), + 'description': traverse_obj(next_data, ('long_description', {clean_html})) or video.get('description'), + 'thumbnail': traverse_obj(video, ('poster', {url_or_none})) or self._og_search_thumbnail(webpage), 'duration': float_or_none(video.get('duration')), 'timestamp': unified_timestamp(video.get('currentSunrise')), 'series': video.get('label'), @@ -104,20 +106,17 @@ class ServusIE(InfoExtractor): 'episode_number': episode_number, 'formats': formats, 'subtitles': subtitles, - **traverse_obj(next_data, ('props', 'pageProps', 'data', { - 'title': ('title', 'rendered', {str}), - 'timestamp': ('stv_date', 'raw', {int}), - 'duration': ('stv_duration', {float_or_none}), - 'categories': ('category_names', ..., {str}), + **traverse_obj(next_data, { + 'title': ('title', {str}), + 'duration': ('duration', {int_or_none(scale=1000)}), + }), + **traverse_obj(next_data, ('product', { + 'title': ('title', {str}), + 'description': ('long_description', {str}), + 'duration': ('duration', {int_or_none(scale=1000)}), })), } - def _get_description(self, next_data): - return join_nonempty(*traverse_obj(next_data, ( - 'props', 'pageProps', 'data', - ('stv_short_description', 'stv_long_description'), {str}, - {lambda x: x.replace('\n\n', '\n')}, {unescapeHTML})), delim='\n\n') - def _report_errors(self, video): playability_errors = traverse_obj(video, ('playabilityErrors', ...)) if not playability_errors: