From fc1268794ab28c0b3b069a84c7e8df4ef2743816 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 30 Jul 2021 10:06:26 +0200 Subject: [PATCH] better, near-complete age-gate bypass https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-888837000 --- app/common/common.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/app/common/common.py b/app/common/common.py index 5b70548..cfe54a3 100644 --- a/app/common/common.py +++ b/app/common/common.py @@ -221,9 +221,11 @@ def get_video_info(video_id, sts=0, algo="", _embed=False): 'hl': 'en', 'clientName': 'WEB_EMBEDDED_PLAYER' if _embed else 'WEB', 'clientVersion': f'2.{today}.01.01', + 'clientScreen': 'EMBED', #"clientName": "ANDROID", #"clientVersion": "16.02", - } + }, + 'thirdParty': {'embedUrl': 'http://example.com/'} }, 'playbackContext': {'contentPlaybackContext': {'signatureTimestamp': sts}} }, cookies=cookies) @@ -250,20 +252,6 @@ def get_video_info(video_id, sts=0, algo="", _embed=False): metadata['streamingData'] = metadata_embed['streamingData'] metadata['playabilityStatus'] = metadata_embed['playabilityStatus'] else: - try: - r2 = requests.get("https://www.youtube.com/get_video_info", dict( - video_id=video_id, - html5="1", - c="ANDROID", # XXX: randomly 404's as well - cver="16.02", - el="embedded", - eurl=f"https://youtube.googleapis.com/v/{video_id}", - )) - metadata_tvhtml5 = json.loads(parse_qs(r2.text).get('player_response',['{}'])[0]) - # has 'playabilityStatus', 'streamingData', 'videoDetails', but not 'microformat' keys - metadata['streamingData'] = metadata_tvhtml5['streamingData'] - metadata['playabilityStatus'] = metadata_tvhtml5['playabilityStatus'] - except: return None, None, metadata, 'agegated', player_error else: # without videoDetails, there's only the error message -- 2.39.3