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

Code before:
                        'duration': ('duration', {int_or_none}),
                        'timestamp': ('broadcastedOn', {parse_iso8601}),
                    }))

        page_data = call_api(0)
        full_id = join_nonempty(playlist_id, season_number, version, delim='_')

        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,

Review comment (suggestion):
I would inline the URL since it's only used once
```suggestion
    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']

```

Code after:
                        'title': ('longTitle', {str}),
                        'duration': ('duration', {int_or_none}),
                        'timestamp': ('broadcastedOn', {parse_iso8601}),
                    }))

        page_data = call_api(0)
        full_id = join_nonempty(playlist_id, season_number, version, delim='_')

        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',