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

Code before:
        # Sometimes authentication fails for no good reason, retry
        login_attempt = 1
        while login_attempt <= 3:
            try:
                # get XSRF Token
                self._request_webpage('https://token.vrt.be/vrtnuinitlogin',
                                      None, note='Requesting XSRF Token', errnote='Could not get XSRF Token',
                                      query={'provider': 'site', 'destination': 'https://www.vrt.be/vrtnu/'})

                post_data = {
                    'UID': auth_info['UID'],
                    'UIDSignature': auth_info['UIDSignature'],
                    'signatureTimestamp': auth_info['signatureTimestamp'],
                    'client_id': 'vrtnu-site',
                }
                for cookie in self._downloader.cookiejar:
                    if cookie.name == 'OIDCXSRF':
                        post_data['_csrf'] = cookie.value
                        break

                # do login
                self._request_webpage(
                    'https://login.vrt.be/perform_login',
                    None, note='Requesting a token', errnote='Could not get a token',
                    headers={}, data=urlencode_postdata(post_data)
                )

            except ExtractorError as e:
                if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
                    login_attempt += 1
                    self.report_warning('Authentication failed')
                    self._sleep(1, None, msg_template='Waiting for %(timeout)s seconds before trying again')
                else:
                    raise e
            else:
                break

    def _real_extract(self, url):
        display_id = self._match_id(url)

        webpage = self._download_webpage(url, display_id)

        attrs = extract_attributes(self._search_regex(
            r'(<nui-media[^>]+>)', webpage, 'media element'))
        video_id = attrs['videoid']
        publication_id = attrs.get('publicationid')
        if publication_id:
            video_id = publication_id + '$' + video_id

        page = (self._parse_json(self._search_regex(
            r'digitalData\s*=\s*({.+?});', webpage, 'digial data',

Review comment (suggestion):
```suggestion
                    headers={}, data=urlencode_postdata(post_data))
```

Code after:
                                      None, note='Requesting XSRF Token', errnote='Could not get XSRF Token',
                                      query={'provider': 'site', 'destination': 'https://www.vrt.be/vrtnu/'})

                post_data = {
                    'UID': auth_info['UID'],
                    'UIDSignature': auth_info['UIDSignature'],
                    'signatureTimestamp': auth_info['signatureTimestamp'],
                    'client_id': 'vrtnu-site',
                    '_csrf': self._get_cookies('https://login.vrt.be').get('OIDCXSRF').value,
                }

                self._request_webpage(
                    'https://login.vrt.be/perform_login',
                    None, note='Requesting a token', errnote='Could not get a token',
                    headers={}, data=urlencode_postdata(post_data))

            except ExtractorError as e:
                if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
                    login_attempt += 1
                    self.report_warning('Authentication failed')
                    self._sleep(1, None, msg_template='Waiting for %(timeout)s seconds before trying again')
                else:
                    raise e
            else:
                break

    def _real_extract(self, url):
        display_id = self._match_id(url)

        webpage = self._download_webpage(url, display_id)

        attrs = extract_attributes(self._search_regex(
            r'(<nui-media[^>]+>)', webpage, 'media element'))
        video_id = attrs['videoid']
        publication_id = attrs.get('publicationid')
        if publication_id:
            video_id = publication_id + '$' + video_id

        page = (self._parse_json(self._search_regex(
            r'digitalData\s*=\s*({.+?});', webpage, 'digial data',
            default='{}'), video_id, fatal=False) or {}).get('page') or {}

        info = self._search_json_ld(webpage, display_id, default={})
        return merge_dicts(info, {
            '_type': 'url_transparent',
            'url': 'https://mediazone.vrt.be/api/v1/vrtvideo/assets/%s' % video_id,
            'ie_key': CanvasIE.ie_key(),
            'id': video_id,
            'display_id': display_id,
            'season_number': int_or_none(page.get('episode_season')),
        })