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

Code before:
import functools

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    UserNotLive,
    int_or_none,
    parse_iso8601,
    str_or_none,
    url_or_none,
)
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']),

Review comment (refactor):
```suggestion
class NuumBaseIE(InfoExtractor):
    def _call_api(self, path, video_id, description, query={}):
```

Code after:
import functools

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    UserNotLive,
    filter_dict,
    int_or_none,
    parse_iso8601,
    str_or_none,
    url_or_none,
)
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'