Skip to content

Commit

Permalink
fix: Use correct client version value. Add client-name parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Jan 16, 2025
1 parent 2ee47ae commit e03b53b
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.requests.Requester;
import app.revanced.extension.shared.requests.Route;
import app.revanced.extension.shared.settings.AppLanguage;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.spoof.ClientType;

Expand Down Expand Up @@ -45,9 +44,9 @@ static String createInnertubeBody(ClientType clientType, String videoId) {
// but if this is a fall over client it will set the language even though
// the audio language is not selectable in the UI.
ClientType userSelectedClient = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
AppLanguage language = userSelectedClient == ClientType.ANDROID_VR_NO_AUTH
? BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get()
: AppLanguage.DEFAULT;
Locale streamLocale = userSelectedClient == ClientType.ANDROID_VR_NO_AUTH
? BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getLocale()
: Locale.getDefault();

JSONObject client = new JSONObject();
client.put("deviceMake", clientType.deviceMake);
Expand All @@ -65,8 +64,8 @@ static String createInnertubeBody(ClientType clientType, String videoId) {
client.put("chipset", clientType.chipset);
}
}
client.put("hl", language.getLanguage());
client.put("gl", Utils.getContext().getResources().getConfiguration().locale.getCountry());
client.put("hl", streamLocale.getLanguage());
client.put("gl", streamLocale.getCountry());
TimeZone zone = TimeZone.getDefault();
client.put("timeZone", zone.getID());
client.put("utcOffsetMinutes", zone.getOffset(new Date().getTime()) / 60000);
Expand All @@ -91,7 +90,8 @@ static HttpURLConnection getPlayerResponseConnectionFromRoute(Route.CompiledRout

connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("User-Agent", clientType.userAgent);
connection.setRequestProperty("X-YouTube-Client-Version", String.valueOf(clientType.id));
connection.setRequestProperty("X-YouTube-Client-Name", String.valueOf(clientType.id));
connection.setRequestProperty("X-YouTube-Client-Version", clientType.clientName);

connection.setUseCaches(false);
connection.setDoOutput(true);
Expand Down

0 comments on commit e03b53b

Please sign in to comment.