mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-01 03:56:21 +02:00
[ie/youtube] Fix initial player response usage (Bugfix for 8b8b442cb0
) (#10464)
Authored by: seproDev
This commit is contained in:
parent
959b7a379b
commit
16da8ef993
@ -3702,17 +3702,17 @@ 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:
|
||||||
experiments = traverse_obj(master_ytcfg, (
|
if 'web' in clients:
|
||||||
'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'serializedExperimentIds', {str}, {lambda x: x.split(',')}, ..., {str}))
|
experiments = traverse_obj(master_ytcfg, (
|
||||||
if all(x in experiments for x in self._POTOKEN_EXPERIMENTS):
|
'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'serializedExperimentIds', {lambda x: x.split(',')}, ...))
|
||||||
self.report_warning(
|
if all(x in experiments for x in self._POTOKEN_EXPERIMENTS):
|
||||||
'Webpage contains broken formats (poToken experiment detected). Ignoring initial player response')
|
self.report_warning(
|
||||||
master_ytcfg = self._get_default_ytcfg()
|
'Webpage contains broken formats (poToken experiment detected). Ignoring initial player response')
|
||||||
else:
|
ignore_initial_response = True
|
||||||
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)
|
||||||
|
|
||||||
prs = []
|
prs = []
|
||||||
if initial_pr and not self._invalid_player_response(initial_pr, video_id):
|
if initial_pr and not self._invalid_player_response(initial_pr, video_id):
|
||||||
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user