Skip to content

Commit

Permalink
fix(YouTube - Spoof video streams): Use 2 letter device language code
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Dec 22, 2024
1 parent b87d995 commit 33ff997
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Locale;

import app.revanced.extension.shared.Utils;

public enum AudioStreamLanguage {
/**
* YouTube default.
Expand Down Expand Up @@ -65,8 +67,6 @@ public enum AudioStreamLanguage {
OR,
PA,
PL,
PT_BR,
PT_PT,
RO,
RU,
SI,
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static String createInnertubeBody(ClientType clientType) {
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);
Expand Down
4 changes: 0 additions & 4 deletions patches/src/main/resources/addresources/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<item>@string/revanced_spoof_video_streams_language_OR</item>
<item>@string/revanced_spoof_video_streams_language_PA</item>
<item>@string/revanced_spoof_video_streams_language_PL</item>
<item>@string/revanced_spoof_video_streams_language_PT_BR</item>
<item>@string/revanced_spoof_video_streams_language_PT_PT</item>
<item>@string/revanced_spoof_video_streams_language_RO</item>
<item>@string/revanced_spoof_video_streams_language_RU</item>
<item>@string/revanced_spoof_video_streams_language_SK</item>
Expand Down Expand Up @@ -93,8 +91,6 @@
<item>OR</item>
<item>PA</item>
<item>PL</item>
<item>PT_BR</item>
<item>PT_PT</item>
<item>RO</item>
<item>RU</item>
<item>SK</item>
Expand Down
2 changes: 0 additions & 2 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,6 @@ Video playback may not work"</string>
<string name="revanced_spoof_video_streams_language_OR">Odia</string>
<string name="revanced_spoof_video_streams_language_PA">Punjabi</string>
<string name="revanced_spoof_video_streams_language_PL">Polish</string>
<string name="revanced_spoof_video_streams_language_PT_BR">Portuguese (Brazil)</string>
<string name="revanced_spoof_video_streams_language_PT_PT">Portuguese (Portugal)</string>
<string name="revanced_spoof_video_streams_language_RO">Romanian</string>
<string name="revanced_spoof_video_streams_language_RU">Russian</string>
<string name="revanced_spoof_video_streams_language_SK">Slovak</string>
Expand Down

0 comments on commit 33ff997

Please sign in to comment.