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

Code before:

        webpage = self._download_webpage(
            'https://www.vidlii.com/watch?v=%s' % video_id, video_id)
        formats = []

        def add_format(format_url, height=None):
            try:
                height = int(self._search_regex(r"(?P<h>\d\d\d).mp4",
                                                format_url, "height",
                                                group="h"))
            except Exception:
                height = 360
            formats.append({
                'url': format_url,
                'format_id': '%dp' % height if height else None,
                'height': height,
            })

        hdsrc = self._search_regex(
            r'hdsrc\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1',
            webpage, 'video url', group='url')
        try:
            compat_urllib_request.urlopen(hdsrc)
            add_format(hdsrc)
        except Exception:
            pass
        add_format(self._search_regex(
            r'src\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1',
            webpage, 'video url', group='url'))
        self._sort_formats(formats)

        title = self._search_regex(
            (r'<h1>([^<]+)</h1>', r'<title>([^<]+) - VidLii<'), webpage,
            'title')

        description = self._html_search_meta(
            ('description', 'twitter:description'), webpage,
            default=None) or strip_or_none(
            get_element_by_id('des_text', webpage))

        thumbnail = self._html_search_meta(
            'twitter:image', webpage, default=None)
        if not thumbnail:
            thumbnail_path = self._search_regex(
                r'img\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
                'thumbnail', fatal=False, group='url')
            if thumbnail_path:
                thumbnail = urljoin(url, thumbnail_path)

        uploader = self._search_regex(
            r'<div[^>]+class=["\']wt_person[^>]+>\s*<a[^>]+\bhref=["\']/user/[^>]+>([^<]+)',

Review comment (suggestion):
```py
self._request_webpage(HEADRequest(hdsrc), ...)
```

Code after:
        webpage = self._download_webpage(
            'https://www.vidlii.com/watch?v=%s' % video_id, video_id)
        formats = []

        sources = [source[1] for source in re.findall(
            r'src\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1',
            webpage) or []]
        for source in sources:
            height = int(self._search_regex(r'(\d+).mp4', source, 'height', default=360))
            if self._request_webpage(HEADRequest(source), video_id, f'Checking {height}p url', errnote=False):
                formats.append({
                    'url': source,
                    'format_id': f'{height}p',
                    'height': height,
                })
        self._sort_formats(formats)

        title = self._search_regex(
            (r'<h1>([^<]+)</h1>', r'<title>([^<]+) - VidLii<'), webpage,
            'title')

        description = self._html_search_meta(
            ('description', 'twitter:description'), webpage,
            default=None) or strip_or_none(
            get_element_by_id('des_text', webpage))

        thumbnail = self._html_search_meta(
            'twitter:image', webpage, default=None)
        if not thumbnail:
            thumbnail_path = self._search_regex(
                r'img\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
                'thumbnail', fatal=False, group='url')
            if thumbnail_path:
                thumbnail = urljoin(url, thumbnail_path)

        uploader = self._search_regex(
            r'<div[^>]+class=["\']wt_person[^>]+>\s*<a[^>]+\bhref=["\']/user/[^>]+>([^<]+)',
            webpage, 'uploader', fatal=False)
        uploader_url = 'https://www.vidlii.com/user/%s' % uploader if uploader else None

        upload_date = unified_strdate(self._html_search_meta(
            'datePublished', webpage, default=None) or self._search_regex(
            r'<date>([^<]+)', webpage, 'upload date', fatal=False))

        duration = int_or_none(self._html_search_meta(
            'video:duration', webpage, 'duration',
            default=None) or self._search_regex(
            r'duration\s*:\s*(\d+)', webpage, 'duration', fatal=False))

        view_count = str_to_int(self._search_regex(
            (r'<strong>([,0-9]+)</strong> views',