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

Code before:
from ..utils.traversal import traverse_obj


class NuumBaseIE(InfoExtractor):

    def _call_api(self, path, video_id, description, query={}):
        response = self._download_json(
            f'https://nuum.ru/api/v2/{path}', video_id, query=query,
            note=f'Downloading {description} metadata',
            errnote=f'Unable to download {description} metadata')
        if error := response.get('error'):
            raise ExtractorError(f'API returned error: {error!r}')
        return response.get('result')

    def _get_channel_info(self, channel_name):
        return self._call_api(
            'broadcasts/public', video_id=channel_name, description='channel',
            query={
                'with_extra': 'true',
                'channel_name': channel_name,
                'with_deleted': 'true',
            })

    def _parse_video_data(self, container):
        stream = traverse_obj(container, ('media_container_streams', 0))
        media = traverse_obj(stream, ('stream_media', 0))
        media_url = traverse_obj(media, (
            'media_meta', ('media_archive_url', 'media_url'), {url_or_none}), get_all=False)

        return media_url, {
            'id': str(container['media_container_id']),
            'is_live': media.get('media_status') == 'RUNNING',
            **traverse_obj(container, {
                'title': ('media_container_name', {str}),
                'description': ('media_container_description', {str}),
                'timestamp': ('created_at', {parse_iso8601}),
                'channel': ('media_container_channel', 'channel_name', {str}),
                'channel_id': ('media_container_channel', 'channel_id', {str_or_none}),
            }),
            **traverse_obj(stream, {
                'view_count': ('stream_total_viewers', {int_or_none}),
                'concurrent_view_count': ('stream_current_viewers', {int_or_none}),
            }),
            **traverse_obj(media, {
                'duration': ('media_duration', {int_or_none}),
                'thumbnail': ('media_meta', ('media_preview_archive_url', 'media_preview_url'), {url_or_none}),
            }, get_all=False),
        }


class NuumMediaIE(NuumBaseIE):

Review comment (suggestion):
if the idea is to make this non-fatal we should do this, yeah?
```suggestion
        stream = traverse_obj(container, ('media_container_streams', 0, {dict})) or {}
        media = traverse_obj(stream, ('stream_media', 0, {dict})) or {}
```


Code after:
)
from ..utils.traversal import traverse_obj


class NuumBaseIE(InfoExtractor):
    def _call_api(self, path, video_id, description, query={}):
        response = self._download_json(
            f'https://nuum.ru/api/v2/{path}', video_id, query=query,
            note=f'Downloading {description} metadata',
            errnote=f'Unable to download {description} metadata')
        if error := response.get('error'):
            raise ExtractorError(f'API returned error: {error!r}')
        return response['result']

    def _get_channel_info(self, channel_name):
        return self._call_api(
            'broadcasts/public', video_id=channel_name, description='channel',
            query={
                'with_extra': 'true',
                'channel_name': channel_name,
                'with_deleted': 'true',
            })

    def _parse_video_data(self, container, extract_formats=True):
        stream = traverse_obj(container, ('media_container_streams', 0, {dict})) or {}
        media = traverse_obj(stream, ('stream_media', 0, {dict})) or {}
        media_url = traverse_obj(media, (
            'media_meta', ('media_archive_url', 'media_url'), {url_or_none}), get_all=False)

        video_id = str(container['media_container_id'])
        is_live = media.get('media_status') == 'RUNNING'

        formats, subtitles = None, None
        if extract_formats:
            formats, subtitles = self._extract_m3u8_formats_and_subtitles(
                media_url, video_id, 'mp4', live=is_live)

        return filter_dict({
            'id': video_id,
            'is_live': is_live,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(container, {
                'title': ('media_container_name', {str}),
                'description': ('media_container_description', {str}),
                'timestamp': ('created_at', {parse_iso8601}),
                'channel': ('media_container_channel', 'channel_name', {str}),
                'channel_id': ('media_container_channel', 'channel_id', {str_or_none}),
            }),
            **traverse_obj(stream, {
                'view_count': ('stream_total_viewers', {int_or_none}),