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

Code before:

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

        formats = []
        qualities = {
            'lq': '360p',
            'hq': '720p',
        }

        json_url = f'https://www.nuvid.com/player_config_json/?vid={video_id}&aid=0&domain_id=0&embed=0&check_speed=0'
        video_data = self._download_json(
            json_url, video_id, headers={
                'Accept': 'application/json, text/javascript, */*; q = 0.01',
                'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
            })

        sources = video_data.get('files')
        for quality, source in sources.items():
            if not source:
                continue
            formats.append({
                'url': source,
                'format_id': qualities.get(quality),
                'height': int_or_none(qualities.get(quality)[:-1]),
            })
        self._check_formats(formats, video_id)
        self._sort_formats(formats)

        title = video_data.get('title')
        thumbnail_base_url = try_get(video_data, lambda x: x['thumbs']['url'])
        thumbnail_extension = try_get(video_data, lambda x: x['thumbs']['extension'])
        thumbnail_id = self._search_regex(
            r'/media/videos/tmb/6523263/preview/(/d+)' + thumbnail_extension, video_data.get('poster', ''), 'thumbnail id', default=19)
        thumbnail = f'{thumbnail_base_url}player/{thumbnail_id}{thumbnail_extension}'
        duration = parse_duration(video_data.get('duration') or video_data.get('duration_format'))

        return {
            'id': video_id,
            'formats': formats,
            'title': title,
            'thumbnail': thumbnail,
            'duration': duration,
            'age_limit': 18,
            'http_headers': {
                'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
                'Sec-Fetch-Dest': 'video',
                'Sec-Fetch-Mode': 'no-cors',
                'Sec-Fetch-Site': 'same-site',
                'DNT': '1',
            }

Review comment (suggestion):
```suggestion
        formats = [{
            'url': source,
            'format_id': qualities.get(quality),
            'height': int_or_none(qualities.get(quality)[:-1]),
        } for quality, source in video_data.get('files').items() if source]
```

Code after:

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

        qualities = {
            'lq': '360p',
            'hq': '720p',
        }

        json_url = f'https://www.nuvid.com/player_config_json/?vid={video_id}&aid=0&domain_id=0&embed=0&check_speed=0'
        video_data = self._download_json(
            json_url, video_id, headers={
                'Accept': 'application/json, text/javascript, */*; q = 0.01',
                'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
            })

        formats = [{
            'url': source,
            'format_id': qualities.get(quality),
            'height': int_or_none(qualities.get(quality)[:-1]),
        } for quality, source in video_data.get('files').items() if source]

        self._check_formats(formats, video_id)
        self._sort_formats(formats)

        title = video_data.get('title')
        thumbnail_base_url = try_get(video_data, lambda x: x['thumbs']['url'])
        thumbnail_extension = try_get(video_data, lambda x: x['thumbs']['extension'])
        thumbnail_id = self._search_regex(
            r'/media/videos/tmb/6523263/preview/(/d+)' + thumbnail_extension, video_data.get('poster', ''), 'thumbnail id', default=19)
        thumbnail = f'{thumbnail_base_url}player/{thumbnail_id}{thumbnail_extension}'
        duration = parse_duration(video_data.get('duration') or video_data.get('duration_format'))

        return {
            'id': video_id,
            'formats': formats,
            'title': title,
            'thumbnail': thumbnail,
            'duration': duration,
            'age_limit': 18,
        }