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

Code before:
        return self.playlist_result(
            OnDemandPagedList(fetch_page, self._PAGE_SIZE), full_id, display_id=display_id,
            title=page_data.get('title'), description=page_data.get('synopsis'))


class ARDAudiothekBaseIE(InfoExtractor):
    _GRAPHQL_ENDPOINT = 'https://api.ardaudiothek.de/graphql'

    def _graphql_query(self, urn, query):
        return self._download_json(
            self._GRAPHQL_ENDPOINT,
            urn,
            data=json.dumps({'query': query,
                             'variables': {'id': urn},
                             }).encode(),
            headers={
                'Content-Type': 'application/json',
            },
        )['data']


class ARDAudiothekIE(ARDAudiothekBaseIE):
    _VALID_URL = r'''(?x)https:?//
        (?:www\.)?ardaudiothek\.de/
        episode/
        (?P<id>urn:ard:(?:episode|section|extra):[a-f0-9]{16})/$'''

    _TESTS = [
        {
            'url': 'https://www.ardaudiothek.de/episode/urn:ard:episode:eabead1add170e93/',
            'info_dict': {
                'id': 'urn:ard:episode:eabead1add170e93',
                'ext': 'mp3',
                'upload_date': '20240717',
                'duration': 3339,
                'title': 'CAIMAN CLUB (S04E04): Cash Out',
                'thumbnail': 'https://api.ardmediathek.de/image-service/images/urn:ard:image:ed64411a07a4b405',
                'description': 'md5:0e5d127a3832ae59e8bab40a91a5dadc',
                'display_id': 'urn:ard:episode:eabead1add170e93',
                'timestamp': 1721181641,
                'series': '1LIVE Caiman Club',
                'channel': 'WDR',
                'episode': 'Episode 4',
                'episode_number': 4,
                'abr': 256,
                'acodec': 'MP3',
            },
        },
        {
            'url': 'https://www.ardaudiothek.de/episode/urn:ard:section:855c7a53dac72e0a/',
            'info_dict': {

Review comment (suggestion):
I would just keep this as a single line. Any reason for the `$` anchor? It would exclude URLs that contain query args or fragments.
```suggestion
    _VALID_URL = r'https:?//(?:www\.)?ardaudiothek\.de/episode/(?P<id>urn:ard:(?:episode|section|extra):[a-f0-9]{16})'
```

Code after:

        return self.playlist_result(
            OnDemandPagedList(fetch_page, self._PAGE_SIZE), full_id, display_id=display_id,
            title=page_data.get('title'), description=page_data.get('synopsis'))


class ARDAudiothekBaseIE(InfoExtractor):
    def _graphql_query(self, urn, query):
        return self._download_json(
            'https://api.ardaudiothek.de/graphql', urn,
            data=json.dumps({
                'query': query,
                'variables': {'id': urn},
            }).encode(), headers={
                'Content-Type': 'application/json',
            })['data']


class ARDAudiothekIE(ARDAudiothekBaseIE):
    _VALID_URL = r'https:?//(?:www\.)?ardaudiothek\.de/episode/(?P<id>urn:ard:(?:episode|section|extra):[a-f0-9]{16})'

    _TESTS = [{
        'url': 'https://www.ardaudiothek.de/episode/urn:ard:episode:eabead1add170e93/',
        'info_dict': {
            'id': 'urn:ard:episode:eabead1add170e93',
            'ext': 'mp3',
            'upload_date': '20240717',
            'duration': 3339,
            'title': 'CAIMAN CLUB (S04E04): Cash Out',
            'thumbnail': 'https://api.ardmediathek.de/image-service/images/urn:ard:image:ed64411a07a4b405',
            'description': 'md5:0e5d127a3832ae59e8bab40a91a5dadc',
            'display_id': 'urn:ard:episode:eabead1add170e93',
            'timestamp': 1721181641,
            'series': '1LIVE Caiman Club',
            'channel': 'WDR',
            'episode': 'Episode 4',
            'episode_number': 4,
        },
    }, {
        'url': 'https://www.ardaudiothek.de/episode/urn:ard:section:855c7a53dac72e0a/',
        'info_dict': {
            'id': 'urn:ard:section:855c7a53dac72e0a',
            'ext': 'mp4',
            'upload_date': '20241231',
            'duration': 3304,
            'title': 'Illegaler DDR-Detektiv: Doberschütz und die letzte Staatsjagd (1/2) - Wendezeit',
            'thumbnail': 'https://api.ardmediathek.de/image-service/images/urn:ard:image:b9b4f1e8b93da4dd',
            'description': 'md5:3552d571e1959754cff66c1da6c0fdae',
            'display_id': 'urn:ard:section:855c7a53dac72e0a',
            'timestamp': 1735629900,
            'series': 'Auf der Spur – Die ARD Ermittlerkrimis',