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

Code before:
    }, {
        'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/vot-eto-focus-dedy-morozy-na-gidrociklah-60c7c443da18892ebfe85ed7',
        'info_dict': {
            'id': '60c7c443da18892ebfe85ed7',
            'ext': 'mp4',
            'title': 'ВОТ ЭТО Focus. Деды Морозы на гидроциклах',
            'description': 'md5:8684912f6086f298f8078d4af0e8a600',
            'thumbnail': 'https://avatars.mds.yandex.net/get-zen-pub-og/4410519/pub_60c7c443da18892ebfe85ed7_60c7c48e060a163121f42cc3/orig',
            'uploader': 'AcademeG DailyStream'
        },
    }, {
        'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/novyi-samsung-fold-3-moskvich-barahlit-612f93b7f8d48e7e945792a2?from=channel&rid=2286618386.482.1630817595976.42360',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        id = self._match_id(url)
        webpage = self._download_webpage(url, id)
        data_json = self._parse_json(self._search_regex(r'w\._data\s?=\s?({.+?});', webpage, 'metadata'), id)
        stream_json = try_get(data_json, lambda x: x['publication']['content']['gifContent'], dict)
        stream_url = stream_json.get('stream') or try_get(stream_json, lambda x: x['streams']['url'])
        formats = self._extract_m3u8_formats(stream_url, id)
        self._sort_formats(formats)
        return {
            'id': id,
            'title': try_get(data_json, lambda x: x['og']['title']) or try_get(data_json, lambda x: x['publication']['content']['preview']['title']),
            'uploader': data_json.get('authorName') or try_get(data_json, lambda x: x['publisher']['name']),
            'description': try_get(data_json, lambda x: x['og']['description']),
            'thumbnail': try_get(data_json, lambda x: x['og']['imageUrl']),
            'formats': formats,
        }


class ZenYandexChannelIE(InfoExtractor):
    _VALID_URL = r'https?://zen\.yandex\.ru/(?!media)(?:id/)?(?P<id>[a-z0-9-_]+)'
    _TESTS = [{
        'url': 'https://zen.yandex.ru/tok_media',
        'info_dict': {
            'id': 'tok_media',
        },
        'playlist_mincount': 169,
    }, {
        'url': 'https://zen.yandex.ru/id/606fd806cc13cb3c58c05cf5',
        'info_dict': {
            'id': '606fd806cc13cb3c58c05cf5',
        },
        'playlist_mincount': 657,
    }]

    def _entries(self, id, url):
        webpage = self._download_webpage(url, id)

Review comment (suggestion):
```suggestion
            'title': try_get(data_json, (lambda x: x['og']['title'], lambda x: x['publication']['content']['preview']['title'])),
```

Code after:
    }, {
        'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/vot-eto-focus-dedy-morozy-na-gidrociklah-60c7c443da18892ebfe85ed7',
        'info_dict': {
            'id': '60c7c443da18892ebfe85ed7',
            'ext': 'mp4',
            'title': 'ВОТ ЭТО Focus. Деды Морозы на гидроциклах',
            'description': 'md5:8684912f6086f298f8078d4af0e8a600',
            'thumbnail': 'https://avatars.mds.yandex.net/get-zen-pub-og/4410519/pub_60c7c443da18892ebfe85ed7_60c7c48e060a163121f42cc3/orig',
            'uploader': 'AcademeG DailyStream'
        },
    }, {
        'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/novyi-samsung-fold-3-moskvich-barahlit-612f93b7f8d48e7e945792a2?from=channel&rid=2286618386.482.1630817595976.42360',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        id = self._match_id(url)
        webpage = self._download_webpage(url, id)
        data_json = self._parse_json(self._search_regex(r'w\._data\s?=\s?({.+?});', webpage, 'metadata'), id)
        stream_json = try_get(data_json, lambda x: x['publication']['content']['gifContent'], dict)
        stream_url = stream_json.get('stream') or try_get(stream_json, lambda x: x['streams']['url'])
        formats = self._extract_m3u8_formats(stream_url, id)
        self._sort_formats(formats)
        return {
            'id': id,
            'title': try_get(data_json, (lambda x: x['og']['title'], lambda x: x['publication']['content']['preview']['title'])),
            'uploader': data_json.get('authorName') or try_get(data_json, lambda x: x['publisher']['name']),
            'description': try_get(data_json, lambda x: x['og']['description']),
            'thumbnail': try_get(data_json, lambda x: x['og']['imageUrl']),
            'formats': formats,
        }


class ZenYandexChannelIE(InfoExtractor):
    _VALID_URL = r'https?://zen\.yandex\.ru/(?!media)(?:id/)?(?P<id>[a-z0-9-_]+)'
    _TESTS = [{
        'url': 'https://zen.yandex.ru/tok_media',
        'info_dict': {
            'id': 'tok_media',
        },
        'playlist_mincount': 169,
    }, {
        'url': 'https://zen.yandex.ru/id/606fd806cc13cb3c58c05cf5',
        'info_dict': {
            'id': '606fd806cc13cb3c58c05cf5',
        },
        'playlist_mincount': 657,
    }]

    def _entries(self, id, url):
        webpage = self._download_webpage(url, id)