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

Code before:
            self._downloader._first_webpage_request = False

        if note is None:
            self.report_download_webpage(video_id)
        elif note is not False:
            if video_id is None:
                self.to_screen(str(note))
            else:
                self.to_screen(f'{video_id}: {note}')

        # Some sites check X-Forwarded-For HTTP header in order to figure out
        # the origin of the client behind proxy. This allows bypassing geo
        # restriction by faking this header's value to IP that belongs to some
        # geo unrestricted country. We will do so once we encounter any
        # geo restriction error.
        if self._x_forwarded_for_ip:
            headers = (headers or {}).copy()
            headers.setdefault('X-Forwarded-For', self._x_forwarded_for_ip)

        extensions, requested_targets = {}, []
        if impersonate is True:
            requested_targets.append(ImpersonateTarget())
        elif isinstance(impersonate, ImpersonateTarget):
            requested_targets.append(impersonate)
        elif isinstance(impersonate, (str, list, tuple)):
            requested_targets = tuple(map(ImpersonateTarget.from_str, variadic(impersonate)))

        available_target = next(filter(self._downloader._impersonate_target_available, requested_targets), None)
        if available_target:
            extensions['impersonate'] = available_target
        elif requested_targets:
            message = 'The extractor is attempting impersonation, but '
            message += (
                'no impersonate target is available' if impersonate in (True, '', ':')
                else f'these impersonate targets are not available: "{", ".join(map(str, requested_targets))}"')
            info_msg = ('see  https://github.com/yt-dlp/yt-dlp#impersonation  '
                        'for information on installing the required dependencies')
            if require_impersonation:
                raise ExtractorError(f'{message}; {info_msg}', expected=True)
            self.report_warning(f'{message}; if you encounter errors, then {info_msg}', only_once=True)

        try:
            return self._downloader.urlopen(self._create_request(url_or_request, data, headers, query, extensions))
        except network_exceptions as err:
            if isinstance(err, HTTPError):
                if self.__can_accept_status_code(err, expected_status):
                    return err.response

            if errnote is False:
                return False
            if errnote is None:

Review comment (suggestion):
* If none of these match, the argument is silently ignored? We should error instead imo.
* Shouldn't it also support `list[ImpersonateTarget]` for consistency?

```suggestion
        if impersonate is True:
            impersonate = ['']
        requested_targets = [
            x if isinstance(x, ImpersonateTarget) else ImpersonateTarget.from_str(x)
            for x in variadic(impersonate)
        ] if impersonate else []
        extensions = {}
```


Also, do we need `variadic`, or only support list? I'm not sure

Code after:
            self._downloader._first_webpage_request = False

        if note is None:
            self.report_download_webpage(video_id)
        elif note is not False:
            if video_id is None:
                self.to_screen(str(note))
            else:
                self.to_screen(f'{video_id}: {note}')

        # Some sites check X-Forwarded-For HTTP header in order to figure out
        # the origin of the client behind proxy. This allows bypassing geo
        # restriction by faking this header's value to IP that belongs to some
        # geo unrestricted country. We will do so once we encounter any
        # geo restriction error.
        if self._x_forwarded_for_ip:
            headers = (headers or {}).copy()
            headers.setdefault('X-Forwarded-For', self._x_forwarded_for_ip)

        extensions = {}

        if impersonate in (True, ''):
            impersonate = ImpersonateTarget()
        requested_targets = [
            t if isinstance(t, ImpersonateTarget) else ImpersonateTarget.from_str(t)
            for t in variadic(impersonate)
        ] if impersonate else []

        available_target = next(filter(self._downloader._impersonate_target_available, requested_targets), None)
        if available_target:
            extensions['impersonate'] = available_target
        elif requested_targets:
            message = 'The extractor is attempting impersonation, but '
            message += (
                'no impersonate target is available' if not str(impersonate)
                else f'none of these impersonate targets are available: "{", ".join(map(str, requested_targets))}"')
            info_msg = ('see  https://github.com/yt-dlp/yt-dlp#impersonation  '
                        'for information on installing the required dependencies')
            if require_impersonation:
                raise ExtractorError(f'{message}; {info_msg}', expected=True)
            self.report_warning(f'{message}; if you encounter errors, then {info_msg}', only_once=True)

        try:
            return self._downloader.urlopen(self._create_request(url_or_request, data, headers, query, extensions))
        except network_exceptions as err:
            if isinstance(err, HTTPError):
                if self.__can_accept_status_code(err, expected_status):
                    return err.response

            if errnote is False:
                return False