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

Code before:

        metadata = {
            'thumbnail': traverse_obj(
                hydration, ('content', 'currentContent', 'channel', 'image', 'logo', 'path'),
                ('content', 'currentContent', 'resource', 'image', 'cover_desktop', 'path')),
            **traverse_obj(hydration, ('content', 'currentContent', {
                'title': 'title',
                'description': 'description',
            })),
        }

        # Probably it's a program's page
        if not hls_url:
            seasons = traverse_obj(
                hydration, ('content', 'currentContent', 'widgets', lambda _, y: y['type'] == 'seasonList', 'contents'),
                get_all=False)
            if not seasons:
                podcast_episodes = traverse_obj(hydration, ('content', 'currentContent', 'audios'))
                if not podcast_episodes:
                    raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')

                return self.playlist_result([self.url_result(episode['file'], **traverse_obj(episode, {
                    'title': 'title',
                    'description': 'description',
                    'episode_number': ('chapter_number', {lambda x: int_or_none(float_or_none(x))}),
                    'season_number': 'season',
                })) for episode in podcast_episodes], video_id, **metadata)

            entries = []
            for season in seasons:
                for episode in season['contents']:
                    entries.append(self.url_result(urljoin(url, episode['slug']), **{
                        **traverse_obj(season, {
                            'season': 'title',
                            'season_number': 'season',
                        }),
                        **traverse_obj(episode, {
                            'title': 'title',
                            'thumbnail': ('image', 'cover', 'path'),
                            'episode_number': 'chapter_number',
                        })
                    }))

            return self.playlist_result(entries, video_id, **metadata)

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(hls_url, video_id, 'mp4')

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,

Review comment (suggestion):
I was getting some html tags during testing and warnings about non-numeric season number fields
```suggestion
                    'description': ('description', {clean_html}),
                    'episode_number': ('chapter_number', {int_or_none}),
                    'season_number': ('season', {int_or_none}),
```

Code after:

        asset_id = traverse_obj(hydration, ('video', 'assetid'))
        if asset_id:
            hls_url = hydration['base_url_hls'].replace('[node:field_asset_id]', asset_id)
        else:
            hls_url = traverse_obj(hydration, ('channel', 'hls'))

        metadata = traverse_obj(hydration, {
            'title': 'title',
            'description': 'description',
            'thumbnail': ((('channel', 'image', 'logo'), ('resource', 'image', 'cover_desktop')), 'path'),
        }, get_all=False)

        # Probably it's a program's page
        if not hls_url:
            seasons = traverse_obj(
                hydration, ('widgets', lambda _, y: y['type'] == 'seasonList', 'contents'),
                get_all=False)
            if not seasons:
                podcast_episodes = hydration.get('audios')
                if not podcast_episodes:
                    raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')

                return self.playlist_result([
                    self.url_result(episode['file'], url_transparent=True, **traverse_obj(episode, {
                        'title': 'title',
                        'description': ('description', {clean_html}),
                        'episode_number': ('chapter_number', {float_or_none}, {int_or_none}),
                        'season_number': ('season', {int_or_none}),
                    })) for episode in podcast_episodes], video_id, **metadata)

            entries = [self.url_result(
                urljoin(url, episode['slug']), url_transparent=True,
                **traverse_obj(season, {
                    'season': 'title',
                    'season_number': ('season', {int_or_none}),
                }), **traverse_obj(episode, {
                    'title': 'title',
                    'thumbnail': ('image', 'cover', 'path'),
                    'episode_number': ('chapter_number', {int_or_none}),
                })) for season in seasons for episode in traverse_obj(season, ('contents', ...))]

            return self.playlist_result(entries, video_id, **metadata)

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(hls_url, video_id, 'mp4')

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            'is_live': category == 'en-vivo',