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

Code before:
        return {
            'id': video_id,
            'formats': formats,
            'title': video_data.get('def_title'),
            'description': video_data.get('def_description'),
            'tags': video_data.get('def_tags', '').split(','),
            'categories': video_data.get('categories'),
            'thumbnail': video_data.get('src_image_url') or video_data.get('thumbnail'),
            'timestamp': int_or_none(video_data.get(
                'ts_published') or video_data.get('ts_added')),
            'uploader': video_data.get('mcp_id'),
            'duration': int_or_none(video_data.get('duration')),
            'subtitles': subtitles,
        }

    @classmethod
    def _extract_from_webpage(cls, url, webpage):
        for mobj in re.finditer(cls._ANVP_RE, webpage):
            anvplayer_data = unescapeHTML(json.loads(mobj.group('anvp'))) or {}
            video_id, access_key = anvplayer_data.get('video'), anvplayer_data.get('accessKey')
            if not access_key:
                access_key = cls._MCP_TO_ACCESS_KEY_TABLE.get((anvplayer_data.get('mcp') or '').lower())
            if not (video_id or '').isdigit() or not access_key:
                continue
            url = f'anvato:{access_key}:{video_id}'
            if anvplayer_data.get('token') is not None:
                url = smuggle_url(url, {'token': anvplayer_data['token']})
            yield cls.url_result(url, AnvatoIE, video_id)

    def _extract_anvato_videos(self, webpage, video_id):
        anvplayer_data = self._parse_json(
            self._html_search_regex(
                self._ANVP_RE, webpage, 'Anvato player data', group='anvp'),
            video_id)
        return self._get_anvato_videos(
            anvplayer_data['accessKey'], anvplayer_data['video'], 'default')  # cbslocal token = 'default'

    def _real_extract(self, url):
        url, smuggled_data = unsmuggle_url(url, {})
        self._initialize_geo_bypass({
            'countries': smuggled_data.get('geo_countries'),
        })

        access_key, video_id = self._match_valid_url(url).group('access_key_or_mcp', 'id')
        if access_key not in self._ANVACK_TABLE:
            access_key = self._MCP_TO_ACCESS_KEY_TABLE.get(access_key) or access_key
        return self._get_anvato_videos(access_key, video_id, smuggled_data.get('token'))


Review comment (suggestion):
```suggestion
            if anvplayer_data.get('token'):
```

Code after:
        return {
            'id': video_id,
            'formats': formats,
            'title': video_data.get('def_title'),
            'description': video_data.get('def_description'),
            'tags': video_data.get('def_tags', '').split(','),
            'categories': video_data.get('categories'),
            'thumbnail': video_data.get('src_image_url') or video_data.get('thumbnail'),
            'timestamp': int_or_none(video_data.get(
                'ts_published') or video_data.get('ts_added')),
            'uploader': video_data.get('mcp_id'),
            'duration': int_or_none(video_data.get('duration')),
            'subtitles': subtitles,
        }

    @classmethod
    def _extract_from_webpage(cls, url, webpage):
        for mobj in re.finditer(cls._ANVP_RE, webpage):
            anvplayer_data = unescapeHTML(json.loads(mobj.group('anvp'))) or {}
            video_id, access_key = anvplayer_data.get('video'), anvplayer_data.get('accessKey')
            if not access_key:
                access_key = cls._MCP_TO_ACCESS_KEY_TABLE.get((anvplayer_data.get('mcp') or '').lower())
            if not (video_id or '').isdigit() or not access_key:
                continue
            url = f'anvato:{access_key}:{video_id}'
            if anvplayer_data.get('token'):
                url = smuggle_url(url, {'token': anvplayer_data['token']})
            yield cls.url_result(url, AnvatoIE, video_id)

    def _extract_anvato_videos(self, webpage, video_id):
        anvplayer_data = self._parse_json(
            self._html_search_regex(
                self._ANVP_RE, webpage, 'Anvato player data', group='anvp'),
            video_id)
        return self._get_anvato_videos(
            anvplayer_data['accessKey'], anvplayer_data['video'], 'default')  # cbslocal token = 'default'

    def _real_extract(self, url):
        url, smuggled_data = unsmuggle_url(url, {})
        self._initialize_geo_bypass({
            'countries': smuggled_data.get('geo_countries'),
        })

        access_key, video_id = self._match_valid_url(url).group('access_key_or_mcp', 'id')
        if access_key not in self._ANVACK_TABLE:
            access_key = self._MCP_TO_ACCESS_KEY_TABLE.get(access_key) or access_key
        return self._get_anvato_videos(access_key, video_id, smuggled_data.get('token'))