From 80b7f3cd0005b8353eec00d4e59a23e43f1e2fa4 Mon Sep 17 00:00:00 2001 From: Astound Date: Sat, 30 Mar 2024 10:10:35 +0800 Subject: Update user-agents and update android client parameters to fix blockage --- youtube/util.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'youtube/util.py') diff --git a/youtube/util.py b/youtube/util.py index 07d80b1..4c077f6 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -395,22 +395,22 @@ def head(url, use_tor=False, report_text=None, max_redirects=10): return response -mobile_user_agent = 'Mozilla/5.0 (Linux; Android 7.0; Redmi Note 4 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36' +mobile_user_agent = 'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.80 Mobile Safari/537.36' mobile_ua = (('User-Agent', mobile_user_agent),) -desktop_user_agent = 'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0' +desktop_user_agent = 'Mozilla/5.0 (Windows NT 10.0; rv:124.0) Gecko/20100101 Firefox/124.0' desktop_ua = (('User-Agent', desktop_user_agent),) json_header = (('Content-Type', 'application/json'),) desktop_xhr_headers = ( ('Accept', '*/*'), ('Accept-Language', 'en-US,en;q=0.5'), ('X-YouTube-Client-Name', '1'), - ('X-YouTube-Client-Version', '2.20180830'), + ('X-YouTube-Client-Version', '2.20240327.00.00'), ) + desktop_ua mobile_xhr_headers = ( ('Accept', '*/*'), ('Accept-Language', 'en-US,en;q=0.5'), - ('X-YouTube-Client-Name', '2'), - ('X-YouTube-Client-Version', '2.20180830'), + ('X-YouTube-Client-Name', '1'), + ('X-YouTube-Client-Version', '2.20240328.08.00'), ) + mobile_ua @@ -674,11 +674,12 @@ INNERTUBE_CLIENTS = { 'hl': 'en', 'gl': 'US', 'clientName': 'ANDROID', - 'clientVersion': '18.11.34', + 'clientVersion': '19.12.36', 'osName': 'Android', - 'osVersion': '12', - 'androidSdkVersion': 30, - 'userAgent': 'com.google.android.youtube/18.11.34 (Linux; U; Android 12) gzip' + 'osVersion': '14', + 'androidSdkVersion': 34, + 'platform': 'MOBILE', + 'userAgent': 'com.google.android.youtube/19.12.36 (Linux; U; Android 14; US) gzip' }, # https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-887739287 #'thirdParty': { @@ -699,6 +700,7 @@ INNERTUBE_CLIENTS = { 'gl': 'US', 'clientName': 'TVHTML5_SIMPLY_EMBEDDED_PLAYER', 'clientVersion': '2.0', + 'clientScreen': 'EMBED', }, # https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-887739287 'thirdParty': { @@ -715,7 +717,7 @@ INNERTUBE_CLIENTS = { 'INNERTUBE_CONTEXT': { 'client': { 'clientName': 'WEB', - 'clientVersion': '2.20220801.00.00', + 'clientVersion': '2.20240327.00.00', 'userAgent': desktop_user_agent, } }, -- cgit v1.2.3