Skip to content

Commit

Permalink
YouTubeVideoUrl: again update Android client version and parametrs
Browse files Browse the repository at this point in the history
To fix "The following content is not available on this app" in android client.
The android client works much faster than the web, so I give priority to it if possible.

From LuanRT/YouTube.js@d589365"
"
  • Loading branch information
Taapat committed Apr 1, 2024
1 parent 59a3502 commit ca5d480
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/YouTubeVideoUrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def _extract_dash_audio_format(self, streaming_formats, player_id):
def _extract_player_response(self, video_id, client):
player_id = None
url = 'https://www.youtube.com/youtubei/v1/player?key=%s&bpctr=9999999999&has_verified=1' % (YT_EMBKEY if client == 85 else YT_KEY)
USER_AGENT = 'com.google.android.youtube/19.09.37 (Linux; U; Android 12) gzip'
ANDROID = '18.48.37'
USER_AGENT = 'com.google.android.youtube/%s(Linux; U; Android 13; en_US; sdk_gphone64_x86_64 Build/UPB4.230623.005) gzip' % ANDROID
data = {
'videoId': video_id,
'playbackContext': {
Expand Down Expand Up @@ -319,17 +320,17 @@ def _extract_player_response(self, video_id, client):
data['context'] = {
'client': {
'hl': config.plugins.YouTube.searchLanguage.value,
'clientVersion': '19.09.37',
'androidSdkVersion': 31,
'clientVersion': ANDROID,
'androidSdkVersion': 33,
'clientName': 'ANDROID',
'osName': 'Android',
'osVersion': '12',
'osVersion': '13',
'userAgent': USER_AGENT
}
}
data['params'] = 'CgIQBg'
data['params'] = 'CgIIAQ=='
headers['X-YouTube-Client-Name'] = 3
headers['X-YouTube-Client-Version'] = '19.09.37'
headers['X-YouTube-Client-Version'] = ANDROID
headers['User-Agent'] = USER_AGENT
try:
return loads(self._download_webpage(url, data, headers)), player_id
Expand Down

0 comments on commit ca5d480

Please sign in to comment.