mirror of https://github.com/yt-dlp/yt-dlp.git
[youtube] Fix intermittent failure of embed-based age-gate bypass
This commit is contained in:
parent
c15c316b21
commit
2e4cacd038
|
@ -225,28 +225,28 @@ INNERTUBE_CLIENTS = {
|
||||||
|
|
||||||
|
|
||||||
def build_innertube_clients():
|
def build_innertube_clients():
|
||||||
third_party = {
|
THIRD_PARTY = {
|
||||||
'embedUrl': 'https://google.com', # Can be any valid URL
|
'embedUrl': 'https://google.com', # Can be any valid URL
|
||||||
}
|
}
|
||||||
base_clients = ('android', 'web', 'ios', 'mweb')
|
BASE_CLIENTS = ('android', 'web', 'ios', 'mweb')
|
||||||
priority = qualities(base_clients[::-1])
|
priority = qualities(BASE_CLIENTS[::-1])
|
||||||
|
|
||||||
for client, ytcfg in tuple(INNERTUBE_CLIENTS.items()):
|
for client, ytcfg in tuple(INNERTUBE_CLIENTS.items()):
|
||||||
ytcfg.setdefault('INNERTUBE_API_KEY', 'AIzaSyDCU8hByM-4DrUqRUYnGn-3llEO78bcxq8')
|
ytcfg.setdefault('INNERTUBE_API_KEY', 'AIzaSyDCU8hByM-4DrUqRUYnGn-3llEO78bcxq8')
|
||||||
ytcfg.setdefault('INNERTUBE_HOST', 'www.youtube.com')
|
ytcfg.setdefault('INNERTUBE_HOST', 'www.youtube.com')
|
||||||
ytcfg.setdefault('REQUIRE_JS_PLAYER', True)
|
ytcfg.setdefault('REQUIRE_JS_PLAYER', True)
|
||||||
ytcfg['INNERTUBE_CONTEXT']['client'].setdefault('hl', 'en')
|
ytcfg['INNERTUBE_CONTEXT']['client'].setdefault('hl', 'en')
|
||||||
ytcfg['priority'] = 10 * priority(client.split('_', 1)[0])
|
|
||||||
|
|
||||||
if client in base_clients:
|
base_client, *variant = client.split('_')
|
||||||
INNERTUBE_CLIENTS[f'{client}_agegate'] = agegate_ytcfg = copy.deepcopy(ytcfg)
|
ytcfg['priority'] = 10 * priority(base_client)
|
||||||
|
|
||||||
|
if variant == ['embedded']:
|
||||||
|
ytcfg['INNERTUBE_CONTEXT']['thirdParty'] = THIRD_PARTY
|
||||||
|
INNERTUBE_CLIENTS[f'{base_client}_agegate'] = agegate_ytcfg = copy.deepcopy(ytcfg)
|
||||||
agegate_ytcfg['INNERTUBE_CONTEXT']['client']['clientScreen'] = 'EMBED'
|
agegate_ytcfg['INNERTUBE_CONTEXT']['client']['clientScreen'] = 'EMBED'
|
||||||
agegate_ytcfg['INNERTUBE_CONTEXT']['thirdParty'] = third_party
|
|
||||||
agegate_ytcfg['priority'] -= 1
|
agegate_ytcfg['priority'] -= 1
|
||||||
elif client.endswith('_embedded'):
|
|
||||||
ytcfg['INNERTUBE_CONTEXT']['thirdParty'] = third_party
|
|
||||||
ytcfg['priority'] -= 2
|
ytcfg['priority'] -= 2
|
||||||
else:
|
elif variant:
|
||||||
ytcfg['priority'] -= 3
|
ytcfg['priority'] -= 3
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue