Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/servus.py (Python)

Code before:

        return {
            'id': video_id,
            'title': video.get('title'),
            'description': self._get_description(video, video_id),
            'thumbnail': video.get('poster'),
            'duration': float_or_none(video.get('duration')),
            'timestamp': unified_timestamp(video.get('currentSunrise')),
            'series': season,
            'season': video.get('season'),
            'season_number': season_number,
            'episode': episode,
            'episode_number': episode_number,
            'formats': formats,
            'subtitles': subtitles,
        }

    def _get_description(self, video, video_id):
        info = self._download_json("https://backend.servustv.com/wp-json/rbmh/v2/media_asset/aa_id/%s?fieldset=page" % video_id,
                                   video_id, fatal=False)
        if not info:
            return video.get('description')
        description = info.get('stv_long_description') \
            or info.get("stv_short_description") \
            or video.get('description')
        return description

    def _report_errors(self, video):
        if 'playabilityErrors' not in video:
            self.report_warning('No videoUrl, and also no information about errors')
        for error in video.get('playabilityErrors'):
            if error == 'FSK_BLOCKED':
                details = video['playabilityErrorDetails']['FSK_BLOCKED']
                if 'minEveningHour' in details:
                    self.report_warning('Only playable from '
                                        + f'{details["minEveningHour"]}:00 to '
                                        + f'{details["maxMorningHour"]}:00')
            elif error == 'NOT_YET_AVAILABLE':
                self.report_warning('Only available after '
                                    + video.get('currentSunrise'))
            else:
                self.report_warning(f'Not playable: {error}')


Review comment (suggestion):
> [pukkandan](https://github.com/pukkandan) [on Jul 10, 2022](https://github.com/yt-dlp/yt-dlp/pull/4240#discussion_r917394552)
Actually, passing video here only to do a .get on it seems unnecessary. Do this instead:
```suggestion
    def _get_description(self, video_id):
        info = self._download_json(
            f'https://backend.servustv.com/wp-json/rbmh/v2/media_asset/aa_id/{video_id}?fieldset=page',
            video_id, fatal=False)
        return traverse_obj(info, 'stv_long_description', 'stv_short_description')
```
> and above

            'description': self._get_description(video_id) or video.get('description'),

Code after:
        'url': 'https://www.pm-wissen.com/videos/aa-24mus4g2w2112/',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url).upper()

        video = self._download_json(
            'https://api-player.redbull.com/stv/servus-tv?timeZone=Europe/Berlin',
            video_id, 'Downloading video JSON', query={'videoId': video_id})
        if not video.get('videoUrl'):
            self._report_errors(video)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            video['videoUrl'], video_id, 'mp4', m3u8_id='hls')

        season = video.get('season')
        season_number = int_or_none(self._search_regex(
            r'Season (\d+)', season or '', 'season number', default=None))
        episode = video.get('chapter')
        episode_number = int_or_none(self._search_regex(
            r'Episode (\d+)', episode or '', 'episode number', default=None))

        return {
            'id': video_id,
            'title': video.get('title'),
            'description': self._get_description(video_id) or video.get('description'),
            'thumbnail': video.get('poster'),
            'duration': float_or_none(video.get('duration')),
            'timestamp': unified_timestamp(video.get('currentSunrise')),
            'series': video.get('label'),
            'season': season,
            'season_number': season_number,
            'episode': episode,
            'episode_number': episode_number,
            'formats': formats,
            'subtitles': subtitles,
        }

    def _get_description(self, video_id):
        info = self._download_json(
            f'https://backend.servustv.com/wp-json/rbmh/v2/media_asset/aa_id/{video_id}?fieldset=page',
            video_id, fatal=False)

        return join_nonempty(*traverse_obj(info, (
            ('stv_short_description', 'stv_long_description'),
            {lambda x: unescapeHTML(x.replace('\n\n', '\n'))})), delim='\n\n')

    def _report_errors(self, video):
        playability_errors = traverse_obj(video, ('playabilityErrors', ...))
        if not playability_errors:
            raise ExtractorError('No videoUrl and no information about errors')