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

Code before:
            raise ExtractorError('Failed to retrieve a required access token.')

        video_info = self._download_json(
            url_or_request=f'https://api-rtva.interactvty.com/api/2.0/contents/content/{video_id}/',
            video_id=video_id,
            headers={
                'Authorization': f'jwtok {access_token}',
            },
            query={
                'optional_fields': 'description,main_category,image,duration,genre,created_at,publish_date,tags',
            },
        )

        content_resources_linked_to_video: list | None = traverse_obj(
            self._download_json(
                url_or_request=f'https://api-rtva.interactvty.com/api/2.0/contents/content_resources/{video_id}/',
                video_id=video_id,
                headers={
                    'Authorization': f'jwtok {access_token}',
                },
                query={
                    'optional_fields': 'is_initial,media_url',
                },
            ),
            ('results'),
        )

        if type(content_resources_linked_to_video) is not list:
            raise ExtractorError('Failed to retrieve proper information about content resources linked to the specified video.')

        formats = []

        for content_resource_linked_to_video in content_resources_linked_to_video:
            is_initial: bool | None = traverse_obj(
                content_resource_linked_to_video,
                ('is_initial'),
            )

            if is_initial:
                media_url: str | None = traverse_obj(
                    content_resource_linked_to_video,
                    ('media_url'),
                )

                if type(media_url) is str:
                    # Example URL of a M3U8 file for a specific quality (i.e. 480p): https://cdn.rtva.interactvty.com/archivo_ott/el_gran_queo/0000051496/0000051496_480p/0000051496_480p.m3u8
                    formats = self._extract_m3u8_formats(
                        media_url,
                        video_id,
                    )


Review comment (security):
```suggestion
        stream_info = self._download_json(
            f'https://api-rtva.interactvty.com/api/2.0/contents/content_resources/{video_id}/', video_id,
            headers={'Authorization': f'jwtok {access_token}'},
            query={
                'optional_fields': 'media_url',
            })
```

Code after:
                    'password': 'dsUBXUcI',
                }).encode())['access']

        return self._download_json(
            f'{self._API_BASE}/api/2.0/contents/{endpoint}/{video_id}/', video_id,
            f'Downloading {endpoint} API JSON', f'Failed to download {endpoint} API JSON',
            headers={'Authorization': f'jwtok {self._access_token}'},
            query={'optional_fields': ','.join(variadic(fields))} if fields else None)

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = self._call_api('content', video_id, fields=[
            'description', 'image', 'duration', 'created_at', 'tags',
        ])
        stream_info = self._call_api('content_resources', video_id, 'media_url')

        formats, subtitles = [], {}
        for stream_url in traverse_obj(stream_info, ('results', ..., 'media_url', {url_or_none})):
            if determine_ext(stream_url) == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(
                    stream_url, video_id, m3u8_id='hls', fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({'url': stream_url})

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(video_info, {
                'title': ('name', {str.strip}),
                'description': ('description', {str}),
                'thumbnail': ('image', {url_or_none}),
                'duration': ('duration', {float_or_none}),
                'timestamp': ('created_at', {parse_iso8601}),
                'tags': ('tags', ..., {str}),
            }),
        }