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

Code before:
        'only_matching': True,
    }]

    _TOKEN = None

    SUBTITLE_LANGS = {
        'DanishLanguageSubtitles': 'da',
        'ForeignLanguageSubtitles': 'da_foreign',
        'CombinedLanguageSubtitles': 'da_combined',
    }

    def _real_initialize(self):
        if self._TOKEN:
            return
        token_response = self._download_json(
            'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
            note='Downloading anonymous token', headers={
                'content-type': 'application/json',
            },
            query={
                'device': 'web_browser',
                'ff': 'idp,ldp,rpt',
                'lang': 'da',
                'supportFallbackToken': 'true',
            },
            data=json.dumps({
                'deviceId': str(uuid.uuid4()),
                'scopes': [
                    'Catalog',
                ],
                'optout': True,
            }).encode())

        self._TOKEN = traverse_obj(
            token_response, (lambda _, x: x['type'] == 'UserAccount', 'value', {str}), get_all=False)

    def _real_extract(self, url):
        url_slug = self._match_id(url)
        webpage = self._download_webpage(url, url_slug)

        json_data = self._search_json(r'window\.__data\s*=\s*', webpage, 'data', url_slug, fatal=False) or {}
        item = traverse_obj(json_data, ('cache', 'page', ..., (None, ('entries', 0)), 'item'), get_all=False)
        if item:
            item_id = item.get('id')
        else:
            item_id = url_slug.rsplit('_', 1)[-1]
            item = self._download_json(
                f'https://production-cdn.dr-massive.com/api/items/{item_id}', item_id,
                note='Attempting to download backup item data', query={
                    'device': 'web_browser',
                    'expand': 'all',

Review comment (suggestion):
```suggestion
            }, data=json.dumps({
```

Code after:
        'url': 'https://www.dr.dk/drtv/program/jagten_220924',
        'only_matching': True,
    }]

    SUBTITLE_LANGS = {
        'DanishLanguageSubtitles': 'da',
        'ForeignLanguageSubtitles': 'da_foreign',
        'CombinedLanguageSubtitles': 'da_combined',
    }

    _TOKEN = None

    def _real_initialize(self):
        if self._TOKEN:
            return

        token_response = self._download_json(
            'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
            note='Downloading anonymous token', headers={
                'content-type': 'application/json',
            }, query={
                'device': 'web_browser',
                'ff': 'idp,ldp,rpt',
                'lang': 'da',
                'supportFallbackToken': 'true',
            }, data=json.dumps({
                'deviceId': str(uuid.uuid4()),
                'scopes': ['Catalog'],
                'optout': True,
            }).encode())

        self._TOKEN = traverse_obj(
            token_response, (lambda _, x: x['type'] == 'UserAccount', 'value', {str}), get_all=False)
        if not self._TOKEN:
            raise ExtractorError('Unable to get anonymous token')

    def _real_extract(self, url):
        url_slug = self._match_id(url)
        webpage = self._download_webpage(url, url_slug)

        json_data = self._search_json(
            r'window\.__data\s*=', webpage, 'data', url_slug, fatal=False) or {}
        item = traverse_obj(
            json_data, ('cache', 'page', ..., (None, ('entries', 0)), 'item', {dict}), get_all=False)
        if item:
            item_id = item.get('id')
        else:
            item_id = url_slug.rsplit('_', 1)[-1]
            item = self._download_json(
                f'https://production-cdn.dr-massive.com/api/items/{item_id}', item_id,
                note='Attempting to download backup item data', query={