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

Code before:

            player_url = player_url or self._extract_player_url(master_ytcfg, player_ytcfg, webpage=webpage)
            require_js_player = self._get_default_ytcfg(client).get('REQUIRE_JS_PLAYER')
            if 'js' in self._configuration_arg('player_skip'):
                require_js_player = False
                player_url = None

            if not player_url and not tried_iframe_fallback and require_js_player:
                player_url = self._download_player_url(video_id)
                tried_iframe_fallback = True

            visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
            data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
            po_token = self.fetch_po_token(
                client=client, visitor_data=visitor_data,
                data_sync_id=data_sync_id if self.is_authenticated else None,
                player_url=player_url if require_js_player else None,
            )

            require_po_token = self._get_default_ytcfg(client).get('REQUIRE_PO_TOKEN')
            if not po_token and require_po_token:
                self.report_warning(
                    f'No PO Token provided for {client} client. '
                    f'A PO Token is required by this client for working formats. '
                    f'You can manually pass a PO Token for this client with '
                    f'--extractor-args youtube:po_token={client}+XXX',
                    only_once=True)
                deprioritize_pr = True

            pr = initial_pr if client == 'web' else None
            try:
                pr = pr or self._extract_player_response(
                    client, video_id,
                    master_ytcfg=player_ytcfg or master_ytcfg,
                    player_ytcfg=player_ytcfg,
                    player_url=player_url,
                    initial_pr=initial_pr,
                    visitor_data=visitor_data,
                    data_sync_id=data_sync_id,
                    po_token=po_token,
                )
            except ExtractorError as e:
                self.report_warning(e)
                continue

            if pr_id := self._invalid_player_response(pr, video_id):
                skipped_clients[client] = pr_id
            elif pr:
                # Save client name for introspection later
                sd = traverse_obj(pr, ('streamingData', {dict})) or {}
                sd[STREAMING_DATA_CLIENT_NAME] = client

Review comment (refactor):
```suggestion
                    f'--extractor-args "youtube:po_token={client}+XXX"',
```

Code after:
            po_token = self.fetch_po_token(
                client=client, visitor_data=visitor_data,
                data_sync_id=data_sync_id if self.is_authenticated else None,
                player_url=player_url if require_js_player else None,
            )

            require_po_token = self._get_default_ytcfg(client).get('REQUIRE_PO_TOKEN')
            if not po_token and require_po_token:
                self.report_warning(
                    f'No PO Token provided for {client} client, '
                    f'which is required for working {client} formats. '
                    f'You can manually pass a PO Token for this client with '
                    f'--extractor-args "youtube:po_token={client}+XXX"',
                    only_once=True)
                deprioritize_pr = True

            pr = initial_pr if client == 'web' else None
            try:
                pr = pr or self._extract_player_response(
                    client, video_id,
                    master_ytcfg=player_ytcfg or master_ytcfg,
                    player_ytcfg=player_ytcfg,
                    player_url=player_url,
                    initial_pr=initial_pr,
                    visitor_data=visitor_data,
                    data_sync_id=data_sync_id,
                    po_token=po_token)
            except ExtractorError as e:
                self.report_warning(e)
                continue

            if pr_id := self._invalid_player_response(pr, video_id):
                skipped_clients[client] = pr_id
            elif pr:
                # Save client name for introspection later
                sd = traverse_obj(pr, ('streamingData', {dict})) or {}
                sd[STREAMING_DATA_CLIENT_NAME] = client
                sd[STREAMING_DATA_PO_TOKEN] = po_token
                for f in traverse_obj(sd, (('formats', 'adaptiveFormats'), ..., {dict})):
                    f[STREAMING_DATA_CLIENT_NAME] = client
                    f[STREAMING_DATA_PO_TOKEN] = po_token
                if deprioritize_pr:
                    deprioritized_prs.append(pr)
                else:
                    prs.append(pr)

            # tv_embedded can work around age-gate and age-verification IF the video is embeddable
            if self._is_agegated(pr) and variant != 'tv_embedded':
                append_client(f'tv_embedded.{base_client}')

            # Unauthenticated users will only get tv_embedded client formats if age-gated