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

Code before:
            'ext': 'mp4',
            'title': 'Gissy Talks: YouTube Alternatives',
            'thumbnail': r're:^https?://.*\.jpg$',
            'description': 'md5:e65036f0d4af80e0af191bd11af5195e',
            'uploader': 'GissyEva',
            'duration': 630.451,
        }
    }]

    def _extract_formats(self, wvplayer_props):
        # Taken from WeVidi player JS: https://wevidi.net/layouts/default/static/player.min.js
        resolution_map = {
            1: '144p',
            2: '240p',
            3: '360p',
            4: '480p',
            5: '720p',
            6: '1080p'
        }

        srcUID = wvplayer_props.get('srcUID')
        srcVID = wvplayer_props.get('srcVID')
        srcNAME = wvplayer_props.get('srcNAME')
        resolutions = [res for res in wvplayer_props.get('resolutions') if res > 0]
        formats = []
        for res in resolutions:
            format_id = str(-(res // -2) - 1)
            formats.append({
                'acodec': 'mp4a.40.2',
                'ext': 'mp4',
                'format_id': format_id,
                'resolution': resolution_map.get(res),
                'url': f'https://www.wevidi.net/videoplayback/{srcVID}/{srcUID}/{srcNAME}/{format_id}',
                'vcodec': 'avc1.42E01E',
            })

        return formats

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        title = get_element_by_class('video_title', webpage)
        wvplayer_props = json.loads(js_to_json(self._search_regex(
            r'WVPlayer\(({.+?)autoplay', webpage,
            'wvplayer_props', flags=re.DOTALL) + '}'))

        return {
            'id': video_id,
            'title': title,
            'description': clean_html(get_element_by_class('descr_long', webpage)),

Review comment (refactor):
`traverse_obj` can make this safer (import from utils)
```suggestion
        formats = []
        for res in traverse_obj(wvplayer_props, ('resolutions', ..., {int}, {lambda x: x or None})):
```
does the site actually use `0` and we need to avoid it? if not, we could simplify to:
```suggestion
        formats = []
        for res in traverse_obj(wvplayer_props, ('resolutions', ..., {int})):
```

Code after:
            'thumbnail': r're:^https?://.*\.jpg$',
            'description': 'md5:e65036f0d4af80e0af191bd11af5195e',
            'uploader': 'GissyEva',
            'duration': 630.451,
        }
    }, {
        'url': 'https://wevidi.net/watch/4m1c4yJR_yc',
        'md5': 'c63ce5ca6990dce86855fc02ca5bc1ed',
        'info_dict': {
            'id': '4m1c4yJR_yc',
            'ext': 'mp4',
            'title': 'Enough of that! - Awesome Exilez Podcast',
            'thumbnail': r're:^https?://.*\.jpg$',
            'description': 'md5:96af99dd63468b2dfab3020560e3e9b2',
            'uploader': 'eclecRC',
            'duration': 6.804,
        }
    }]

    def _extract_formats(self, wvplayer_props):
        # Taken from WeVidi player JS: https://wevidi.net/layouts/default/static/player.min.js
        resolution_map = {
            1: 144,
            2: 240,
            3: 360,
            4: 480,
            5: 720,
            6: 1080
        }

        src_path = f'{wvplayer_props["srcVID"]}/{wvplayer_props["srcUID"]}/{wvplayer_props["srcNAME"]}'
        for res in traverse_obj(wvplayer_props, ('resolutions', ..., {int}, {lambda x: x or None})):
            format_id = str(-(res // -2) - 1)
            yield {
                'acodec': 'mp4a.40.2',
                'ext': 'mp4',
                'format_id': format_id,
                'height': resolution_map.get(res),
                'url': f'https://www.wevidi.net/videoplayback/{src_path}/{format_id}',
                'vcodec': 'avc1.42E01E',
            }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        wvplayer_props = self._search_json(
            r'WVPlayer\(', webpage, 'player', video_id,
            transform_source=lambda x: js_to_json(x.replace('||', '}')))

        return {