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

Code before:
from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    parse_iso8601,
)


class MaveBaseIE(InfoExtractor):
    _API_BASE_URL = 'https://api.mave.digital/v1/website'
    _API_BASE_STORAGE_URL = 'https://store.cloud.mts.ru/mave/'

    def _load_channel_meta(self, channel_id):
        return self._download_json(
            f'{self._API_BASE_URL}/{channel_id}/',
            channel_id)

    def _load_episode_meta(self, channel_id, episode_code):
        return self._download_json(
            f'{self._API_BASE_URL}/{channel_id}/episodes/{episode_code}',
            episode_code)

    def _create_entry(self, channel_id, channel_meta, episode_meta):
        display_id = f'{channel_id}-{episode_meta["code"]}'

        reactions = episode_meta.get('reactions')

        return {
            'display_id': display_id,
            'channel_id': channel_id,
            'channel_url': f'https://{channel_id}.mave.digital/',
            'vcodec': 'none',
            'thumbnail': self._API_BASE_STORAGE_URL + episode_meta['image'],
            'url': self._API_BASE_STORAGE_URL + episode_meta['audio'],
            'id': episode_meta['id'],
            'title': episode_meta['title'],
            'description': clean_html(episode_meta['description']),
            'duration': int_or_none(episode_meta['duration']),
            'season_number': int_or_none(episode_meta['season']),
            'episode_number': int_or_none(episode_meta['number']),
            'view_count': int_or_none(episode_meta['listenings']),
            'like_count': next(
                (int(r['count']) for r in reactions
                 if r['type'] == 'like'),
                0,
            ) if reactions else None,

Review comment (suggestion):
same here
```suggestion
        return self._download_json(
            f'{self._API_BASE_URL}/{channel_id}/episodes/{episode_code}',
            episode_code, note='Downloading episode metadata')
```

Code after:
import functools
import math

from .common import InfoExtractor
from ..utils import (
    InAdvancePagedList,
    clean_html,
    int_or_none,
    parse_iso8601,
    urljoin,
)
from ..utils.traversal import require, traverse_obj


class MaveBaseIE(InfoExtractor):
    _API_BASE_URL = 'https://api.mave.digital/v1/website'
    _API_BASE_STORAGE_URL = 'https://store.cloud.mts.ru/mave/'

    def _load_channel_meta(self, channel_id, display_id):
        return traverse_obj(self._download_json(
            f'{self._API_BASE_URL}/{channel_id}/', display_id,
            note='Downloading channel metadata'), 'podcast')

    def _load_episode_meta(self, channel_id, episode_code, display_id):
        return self._download_json(
            f'{self._API_BASE_URL}/{channel_id}/episodes/{episode_code}',
            display_id, note='Downloading episode metadata')

    def _create_entry(self, channel_id, channel_meta, episode_meta):
        episode_code = traverse_obj(episode_meta, ('code', {int}, {require('episode code')}))
        return {
            'display_id': f'{channel_id}-{episode_code}',
            'extractor_key': MaveIE.ie_key(),
            'extractor': MaveIE.IE_NAME,
            'webpage_url': f'https://{channel_id}.mave.digital/ep-{episode_code}',
            'channel_id': channel_id,
            'channel_url': f'https://{channel_id}.mave.digital/',
            'vcodec': 'none',
            **traverse_obj(episode_meta, {
                'id': ('id', {str}),
                'url': ('audio', {urljoin(self._API_BASE_STORAGE_URL)}),
                'title': ('title', {str}),
                'description': ('description', {clean_html}),
                'thumbnail': ('image', {urljoin(self._API_BASE_STORAGE_URL)}),
                'duration': ('duration', {int_or_none}),
                'season_number': ('season', {int_or_none}),