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

Code before:
                    }
                if known_idx == last_seq:
                    no_fragment_score += 5
                else:
                    no_fragment_score = 0
                known_idx = last_seq
            except ExtractorError:
                continue

            if manifestless_orig_fmt:
                # Stop at the first iteration if running for post-live manifestless;
                # fragment count no longer increase since it starts
                break

            time.sleep(max(0, FETCH_SPAN + fetch_time - time.time()))

    def _get_player_js_version(self):
        player_js_version = self._configuration_arg('player_js_version', [''])[0] or '20348@0004de42'
        if player_js_version == 'actual':
            return None, None
        if not re.match(r'^[0-9]+@[0-9a-f]{8}$', player_js_version):
            self.report_warning(
                f'Invalid player JS version "{player_js_version}" specified. '
                f'It should be "actual" or in the form "sts@hash" i.e. "20348@0004de42"', only_once=True)
            return None, None
        return player_js_version.split('@')

    def _extract_player_url(self, *ytcfgs, webpage=None):
        player_url = traverse_obj(
            ytcfgs, (..., 'PLAYER_JS_URL'), (..., 'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'jsUrl'),
            get_all=False, expected_type=str)
        if not player_url:
            return
        player_id_override = self._get_player_js_version()[1]

        requested_js_variant = self._configuration_arg('player_js_variant', [''])[0] or 'main'
        if requested_js_variant in self._PLAYER_JS_VARIANT_MAP:
            player_id = player_id_override or self._extract_player_info(player_url)
            original_url = player_url
            player_url = f'/s/player/{player_id}/{self._PLAYER_JS_VARIANT_MAP[requested_js_variant]}'
            if original_url != player_url:
                self.write_debug(
                    f'Forcing "{requested_js_variant}" player JS variant for player {player_id}\n'
                    f'        original url = {original_url}', only_once=True)
        elif requested_js_variant != 'actual':
            self.report_warning(
                f'Invalid player JS variant name "{requested_js_variant}" requested. '
                f'Valid choices are: {", ".join(self._PLAYER_JS_VARIANT_MAP)}', only_once=True)

        return urljoin('https://www.youtube.com', player_url)


Review comment (suggestion):
```suggestion
        if not re.fullmatch(r'[0-9]{5,}@[0-9a-f]{8,}', player_js_version):
            self.report_warning(
                f'Invalid player JS version "{player_js_version}" specified. '
                f'It should be "actual" or in the format of STS@HASH', only_once=True)
            return None, None
        return player_js_version.split('@')
```

Code after:
                    }
                if known_idx == last_seq:
                    no_fragment_score += 5
                else:
                    no_fragment_score = 0
                known_idx = last_seq
            except ExtractorError:
                continue

            if manifestless_orig_fmt:
                # Stop at the first iteration if running for post-live manifestless;
                # fragment count no longer increase since it starts
                break

            time.sleep(max(0, FETCH_SPAN + fetch_time - time.time()))

    def _get_player_js_version(self):
        player_js_version = self._configuration_arg('player_js_version', [''])[0] or '20348@0004de42'
        if player_js_version == 'actual':
            return None, None
        if not re.fullmatch(r'[0-9]{5,}@[0-9a-f]{8,}', player_js_version):
            self.report_warning(
                f'Invalid player JS version "{player_js_version}" specified. '
                f'It should be "actual" or in the format of STS@HASH', only_once=True)
            return None, None
        return player_js_version.split('@')

    def _extract_player_url(self, *ytcfgs, webpage=None):
        player_url = traverse_obj(
            ytcfgs, (..., 'PLAYER_JS_URL'), (..., 'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'jsUrl'),
            get_all=False, expected_type=str)
        if not player_url:
            return
        player_id_override = self._get_player_js_version()[1]

        requested_js_variant = self._configuration_arg('player_js_variant', [''])[0] or 'main'
        if requested_js_variant in self._PLAYER_JS_VARIANT_MAP:
            player_id = player_id_override or self._extract_player_info(player_url)
            original_url = player_url
            player_url = f'/s/player/{player_id}/{self._PLAYER_JS_VARIANT_MAP[requested_js_variant]}'
            if original_url != player_url:
                self.write_debug(
                    f'Forcing "{requested_js_variant}" player JS variant for player {player_id}\n'
                    f'        original url = {original_url}', only_once=True)
        elif requested_js_variant != 'actual':
            self.report_warning(
                f'Invalid player JS variant name "{requested_js_variant}" requested. '
                f'Valid choices are: {", ".join(self._PLAYER_JS_VARIANT_MAP)}', only_once=True)

        return urljoin('https://www.youtube.com', player_url)