1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-17 00:22:34 +01:00

[ie/youtube] Fix initial player response usage (Bugfix for 8b8b442cb0) (#10464)

Authored by: seproDev
This commit is contained in:
sepro 2024-07-14 20:42:11 +02:00 committed by GitHub
parent 959b7a379b
commit 16da8ef993
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3702,15 +3702,15 @@ def _invalid_player_response(self, pr, video_id):
return pr_id return pr_id
def _extract_player_responses(self, clients, video_id, webpage, master_ytcfg, smuggled_data): def _extract_player_responses(self, clients, video_id, webpage, master_ytcfg, smuggled_data):
initial_pr = None initial_pr = ignore_initial_response = None
if webpage: if webpage:
if 'web' in clients:
experiments = traverse_obj(master_ytcfg, ( experiments = traverse_obj(master_ytcfg, (
'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'serializedExperimentIds', {str}, {lambda x: x.split(',')}, ..., {str})) 'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'serializedExperimentIds', {lambda x: x.split(',')}, ...))
if all(x in experiments for x in self._POTOKEN_EXPERIMENTS): if all(x in experiments for x in self._POTOKEN_EXPERIMENTS):
self.report_warning( self.report_warning(
'Webpage contains broken formats (poToken experiment detected). Ignoring initial player response') 'Webpage contains broken formats (poToken experiment detected). Ignoring initial player response')
master_ytcfg = self._get_default_ytcfg() ignore_initial_response = True
else:
initial_pr = self._search_json( initial_pr = self._search_json(
self._YT_INITIAL_PLAYER_RESPONSE_RE, webpage, 'initial player response', video_id, fatal=False) self._YT_INITIAL_PLAYER_RESPONSE_RE, webpage, 'initial player response', video_id, fatal=False)
@ -3740,8 +3740,10 @@ def append_client(*client_names):
skipped_clients = {} skipped_clients = {}
while clients: while clients:
client, base_client, variant = _split_innertube_client(clients.pop()) client, base_client, variant = _split_innertube_client(clients.pop())
player_ytcfg = master_ytcfg if client == 'web' else {} player_ytcfg = {}
if 'configs' not in self._configuration_arg('player_skip') and client != 'web': if client == 'web':
player_ytcfg = self._get_default_ytcfg() if ignore_initial_response else master_ytcfg
elif 'configs' not in self._configuration_arg('player_skip'):
player_ytcfg = self._download_ytcfg(client, video_id) or player_ytcfg player_ytcfg = self._download_ytcfg(client, video_id) or player_ytcfg
player_url = player_url or self._extract_player_url(master_ytcfg, player_ytcfg, webpage=webpage) player_url = player_url or self._extract_player_url(master_ytcfg, player_ytcfg, webpage=webpage)
@ -3754,7 +3756,7 @@ def append_client(*client_names):
player_url = self._download_player_url(video_id) player_url = self._download_player_url(video_id)
tried_iframe_fallback = True tried_iframe_fallback = True
pr = initial_pr if client == 'web' and initial_pr else None pr = initial_pr if client == 'web' and not ignore_initial_response else None
for retry in self.RetryManager(fatal=False): for retry in self.RetryManager(fatal=False):
try: try:
pr = pr or self._extract_player_response( pr = pr or self._extract_player_response(
@ -3765,7 +3767,7 @@ def append_client(*client_names):
break break
experiments = traverse_obj(pr, ( experiments = traverse_obj(pr, (
'responseContext', 'serviceTrackingParams', lambda _, v: v['service'] == 'GFEEDBACK', 'responseContext', 'serviceTrackingParams', lambda _, v: v['service'] == 'GFEEDBACK',
'params', lambda _, v: v['key'] == 'e', 'value', {lambda x: x.split(',')}, ..., {str})) 'params', lambda _, v: v['key'] == 'e', 'value', {lambda x: x.split(',')}, ...))
if all(x in experiments for x in self._POTOKEN_EXPERIMENTS): if all(x in experiments for x in self._POTOKEN_EXPERIMENTS):
pr = None pr = None
retry.error = ExtractorError('API returned broken formats (poToken experiment detected)', expected=True) retry.error = ExtractorError('API returned broken formats (poToken experiment detected)', expected=True)