Skip to content

Commit

Permalink
fix: send correct UA for Android requests
Browse files Browse the repository at this point in the history
Related: #322
  • Loading branch information
LuanRT committed Feb 26, 2023
1 parent 200632f commit f4e0f30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export const CLIENTS = Object.freeze({
},
ANDROID: {
NAME: 'ANDROID',
VERSION: '17.34.35',
SDK_VERSION: '29'
VERSION: '18.06.35',
SDK_VERSION: '29',
USER_AGENT: 'com.google.android.youtube/18.06.35 (Linux; U; Android 10; US)'
},
YTSTUDIO_ANDROID: {
NAME: 'ANDROID_CREATOR',
Expand Down
9 changes: 9 additions & 0 deletions src/utils/HTTPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export default class HTTPClient {

delete n_body.client;


if (Platform.shim.server) {
if (n_body.context.client.clientName === 'ANDROID' || n_body.context.client.clientName === 'ANDROID_MUSIC') {
request_headers.set('User-Agent', Constants.CLIENTS.ANDROID.USER_AGENT);
}
}

is_web_kids = n_body.context.client.clientName === 'WEB_KIDS';
request_body = JSON.stringify(n_body);
}
Expand Down Expand Up @@ -146,12 +153,14 @@ export default class HTTPClient {
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
ctx.client.clientName = Constants.CLIENTS.ANDROID.NAME;
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
ctx.client.platform = 'MOBILE';
break;
case 'YTMUSIC_ANDROID':
ctx.client.clientVersion = Constants.CLIENTS.YTMUSIC_ANDROID.VERSION;
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
ctx.client.clientName = Constants.CLIENTS.YTMUSIC_ANDROID.NAME;
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
ctx.client.platform = 'MOBILE';
break;
case 'YTSTUDIO_ANDROID':
ctx.client.clientVersion = Constants.CLIENTS.YTSTUDIO_ANDROID.VERSION;
Expand Down

0 comments on commit f4e0f30

Please sign in to comment.