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

Code before:
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        description = self._og_search_description(webpage)

        if description == 'Der gewünschte Beitrag ist leider nicht mehr vorhanden.':
            raise ExtractorError(f'Video {video_id} is no longer available', expected=True)

        player_url = traverse_obj(webpage, (
            {find_element(tag='div', id=f'player{video_id}', html=True)},
            {extract_attributes}, 'data-mediacollection-ardplayer',
            {lambda x: self._proto_relative_url(x)},
        ))
        article = traverse_obj(webpage, (
            {find_element(cls='article__content')},
            {find_element(tag='p')}, {clean_html},
        ))
        cls_common = 'teaser__image__caption__text teaser__image__caption__text--'

        return {
            **self._extract_media_info(player_url, webpage, video_id),
            'id': video_id,
            'title': traverse_obj(webpage, (
                {find_element(cls='ardplayer-title')}, {str.strip})),
            'channel': traverse_obj(webpage, (
                {find_element(cls=f'{cls_common}subheadline')},
                {lambda x: x.split('|')[0]}, {str.strip})),
            'description': description,
            'duration': parse_duration(self._search_regex(
                r'(\d{2}:\d{2}:\d{2})', article, 'duration')),
            'release_date': unified_strdate(self._search_regex(
                r'(\d{2}\.\d{2}\.\d{4})', article, 'release_date')),
            'series': traverse_obj(webpage, (
                {find_element(cls=f'{cls_common}headline')}, {str.strip})),
            'series_id': traverse_obj(webpage, (
                {find_element(cls='teaser__link', html=True)},
                {extract_attributes}, 'href', {parse_qs}, 'sen', ..., {str}, any)),
            'thumbnail': self._og_search_thumbnail(webpage),
        }


Review comment (suggestion):
I'd just use `clean_html` in these traversals to be safe (it will take care of the whitespace too).

Instead of `lambda x: x.split('|')[0]` could we use `trim_str` here (e.g. if there's a fixed string after the `|`)?
```suggestion
            'title': traverse_obj(webpage, (
                {find_element(cls='ardplayer-title')}, {clean_html})),
            'channel': traverse_obj(webpage, (
                {find_element(cls=f'{cls_common}subheadline')},
                {lambda x: x.split('|')[0]}, {clean_html})),
```

Code after:
            'thumbnail': r're:https?://.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        description = self._og_search_description(webpage)

        if description == 'Der gewünschte Beitrag ist leider nicht mehr vorhanden.':
            raise ExtractorError(f'Video {video_id} is no longer available', expected=True)

        player_url = traverse_obj(webpage, (
            {find_element(tag='div', id=f'player{video_id}', html=True)},
            {extract_attributes}, 'data-mediacollection-ardplayer',
            {self._proto_relative_url}, {require('player URL')}))
        article = traverse_obj(webpage, (
            {find_element(cls='article__content')},
            {find_element(tag='p')}, {clean_html}))

        return {
            **self._extract_media_info(player_url, webpage, video_id),
            'id': video_id,
            'title': traverse_obj(webpage, (
                {find_element(cls='ardplayer-title')}, {clean_html})),
            'channel': traverse_obj(webpage, (
                {find_element(cls=f'{self._CLS_COMMON}subheadline')},
                {lambda x: x.split('|')[0]}, {clean_html})),
            'description': description,
            'duration': parse_duration(self._search_regex(
                r'(\d{2}:\d{2}:\d{2})', article, 'duration')),
            'release_date': unified_strdate(self._search_regex(
                r'(\d{2}\.\d{2}\.\d{4})', article, 'release_date')),
            'series': traverse_obj(webpage, (
                {find_element(cls=f'{self._CLS_COMMON}headline')}, {clean_html})),
            'series_id': traverse_obj(webpage, (
                {find_element(cls='teaser__link', html=True)},
                {extract_attributes}, 'href', {parse_qs}, 'sen', ..., {str}, any)),
            'thumbnail': self._og_search_thumbnail(webpage),
        }