Update user-agents and update android client parameters to fix blockage

This commit is contained in:
Astound 2024-03-30 10:10:35 +08:00
parent 8b79e067bc
commit 80b7f3cd00
Signed by: kaiser
GPG Key ID: 97504AF0027B1A56
3 changed files with 15 additions and 13 deletions

View File

@ -264,7 +264,7 @@ def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1,
'hl': 'en',
'gl': 'US',
'clientName': 'WEB',
'clientVersion': '2.20180830',
'clientVersion': '2.20240327.00.00',
},
},
'continuation': ctoken,
@ -371,7 +371,7 @@ def get_channel_search_json(channel_id, query, page):
'hl': 'en',
'gl': 'US',
'clientName': 'WEB',
'clientVersion': '2.20180830',
'clientVersion': '2.20240327.00.00',
},
},
'continuation': ctoken,

View File

@ -53,7 +53,7 @@ def request_comments(ctoken, replies=False):
'hl': 'en',
'gl': 'US',
'clientName': 'MWEB',
'clientVersion': '2.20210804.02.00',
'clientVersion': '2.20240328.08.00',
},
},
'continuation': ctoken.replace('=', '%3D'),

View File

@ -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,
}
},