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

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (refactor):
If we make it a `list`, we can make use of `traverse_obj` inline:
```suggestion
        return self.playlist_result(
            traverse_obj(series_data, ('videos', ..., {dict}, {self._extract_url_info})),
            crn_id, serie_data.get('title'), clean_html(serie_data.get('description')))
```

Code after:

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/serien/333485-ein-wunder-fuer-jeden-tag',
        'playlist_mincount': 400,
        'info_dict': {
            'id': '333485',
            'title': 'Ein Wunder für jeden Tag',
            'description': 'Tägliche Kurzandacht mit Déborah Rosenkranz.',
        },
    }]

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        webpage = self._download_webpage(url, crn_id)
        nextjs_data = self._search_nextjs_data(webpage, crn_id)
        series_data = traverse_obj(nextjs_data, ('props', 'pageProps', 'seriePageData', {dict}))
        if not series_data:
            raise ExtractorError('Missing series data.')

        return self.playlist_result(
            traverse_obj(series_data, ('videos', ..., {dict}, {self._extract_url_info})),
            crn_id, series_data.get('title'), clean_html(series_data.get('description')))


class BibelTVLiveIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV live program'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/livestreams/(?P<id>[\w-]+)'
    IE_NAME = 'bibeltv:live'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/livestreams/bibeltv/',
        'info_dict': {
            'id': 'bibeltv',
            'ext': 'mp4',
            'title': 're:Bibel TV',
            'live_status': 'is_live',
            'thumbnail': 'https://streampreview.bibeltv.de/bibeltv.webp',
        },
        'params': {'skip_download': 'm3u8'},
    }, {
        'url': 'https://www.bibeltv.de/livestreams/impuls/',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        stream_id = self._match_id(url)
        webpage = self._download_webpage(url, stream_id)
        stream_data = self._search_json(
            r'\\"video\\":', webpage, 'bibeltvData', stream_id,
            transform_source=lambda jstring: js_to_json(jstring.replace('\\"', '"')))