fix(YouTube - Spoof video streams): Use 2 letter device language code

This commit is contained in:
LisoUseInAIKyrios
2024-12-23 03:37:21 +04:00
parent b87d995587
commit 33ff997200
4 changed files with 8 additions and 21 deletions

View File

@ -2,6 +2,8 @@ package app.revanced.extension.shared.spoof;
import java.util.Locale;
import app.revanced.extension.shared.Utils;
public enum AudioStreamLanguage {
/**
* YouTube default.
@ -65,8 +67,6 @@ public enum AudioStreamLanguage {
OR,
PA,
PL,
PT_BR,
PT_PT,
RO,
RU,
SI,
@ -88,26 +88,19 @@ public enum AudioStreamLanguage {
ZH,
ZU;
private final String iso639_1;
private final String language;
AudioStreamLanguage() {
String name = name();
final int regionSeparatorIndex = name.indexOf('_');
if (regionSeparatorIndex >= 0) {
iso639_1 = name.substring(0, regionSeparatorIndex).toLowerCase(Locale.US)
+ name.substring(regionSeparatorIndex);
} else {
iso639_1 = name().toLowerCase(Locale.US);
}
language = name().toLowerCase(Locale.US);
}
public String getIso639_1() {
public String getLanguage() {
// Changing the app language does not force the app to completely restart,
// so the default needs to be the current language and not a static field.
if (this == DEFAULT) {
return Locale.getDefault().toLanguageTag();
return Locale.getDefault().getLanguage();
}
return iso639_1;
return language;
}
}

View File

@ -37,7 +37,7 @@ final class PlayerRoutes {
JSONObject context = new JSONObject();
JSONObject client = new JSONObject();
client.put("hl", BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getIso639_1());
client.put("hl", BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get().getLanguage());
client.put("clientName", clientType.clientName);
client.put("clientVersion", clientType.clientVersion);
client.put("deviceModel", clientType.deviceModel);