Skip to content

Commit 4017185

Browse files
fix(YouTube - Spoof video streams): Use system language as default iOS audio stream (ReVanced#4042)
1 parent cc40246 commit 4017185

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/Setting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public static boolean importFromJSON(@NonNull Context alertDialogContext, @NonNu
438438
}
439439

440440
for (ImportExportCallback callback : importExportCallbacks) {
441-
callback.settingsExported(alertDialogContext);
441+
callback.settingsImported(alertDialogContext);
442442
}
443443

444444
Utils.showToastLong(numberOfSettingsImported == 0

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/preference/ImportExportPreference.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
7272
builder.setNeutralButton(str("revanced_settings_import_copy"), (dialog, which) -> {
7373
Utils.setClipboard(getEditText().getText().toString());
7474
}).setPositiveButton(str("revanced_settings_import"), (dialog, which) -> {
75-
importSettings(getEditText().getText().toString());
75+
importSettings(builder.getContext(), getEditText().getText().toString());
7676
});
7777
} catch (Exception ex) {
7878
Logger.printException(() -> "onPrepareDialogBuilder failure", ex);
7979
}
8080
}
8181

82-
private void importSettings(String replacementSettings) {
82+
private void importSettings(Context context, String replacementSettings) {
8383
try {
8484
if (replacementSettings.equals(existingSettings)) {
8585
return;
8686
}
8787
AbstractPreferenceFragment.settingImportInProgress = true;
8888

89-
final boolean rebootNeeded = Setting.importFromJSON(Utils.getContext(), replacementSettings);
89+
final boolean rebootNeeded = Setting.importFromJSON(context, replacementSettings);
9090
if (rebootNeeded) {
9191
AbstractPreferenceFragment.showRestartDialog(getContext());
9292
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/requests/PlayerRoutes.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.net.HttpURLConnection;
88

99
import app.revanced.extension.shared.Logger;
10+
import app.revanced.extension.shared.Utils;
1011
import app.revanced.extension.shared.requests.Requester;
1112
import app.revanced.extension.shared.requests.Route;
1213
import app.revanced.extension.youtube.patches.spoof.ClientType;
@@ -24,6 +25,9 @@ final class PlayerRoutes {
2425
*/
2526
private static final int CONNECTION_TIMEOUT_MILLISECONDS = 10 * 1000; // 10 Seconds.
2627

28+
private static final String LOCALE_LANGUAGE = Utils.getContext().getResources()
29+
.getConfiguration().locale.getLanguage();
30+
2731
private PlayerRoutes() {
2832
}
2933

@@ -34,14 +38,15 @@ static String createInnertubeBody(ClientType clientType) {
3438
JSONObject context = new JSONObject();
3539

3640
JSONObject client = new JSONObject();
41+
// Required to use correct default audio channel with iOS.
42+
client.put("hl", LOCALE_LANGUAGE);
3743
client.put("clientName", clientType.name());
3844
client.put("clientVersion", clientType.clientVersion);
3945
client.put("deviceModel", clientType.deviceModel);
4046
client.put("osVersion", clientType.osVersion);
4147
if (clientType.androidSdkVersion != null) {
4248
client.put("androidSdkVersion", clientType.androidSdkVersion);
4349
}
44-
4550
context.put("client", client);
4651

4752
innerTubeBody.put("context", context);

extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/SponsorBlockSettings.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class SponsorBlockSettings {
3030
public static final Setting.ImportExportCallback SB_IMPORT_EXPORT_CALLBACK = new Setting.ImportExportCallback() {
3131
@Override
3232
public void settingsImported(@Nullable Context context) {
33-
updateFromImportedSettings();
33+
SegmentCategory.loadAllCategoriesFromSettings();
3434
}
3535
@Override
3636
public void settingsExported(@Nullable Context context) {
@@ -172,7 +172,7 @@ public static String exportDesktopSettings() {
172172
/**
173173
* Export the categories using flatten json (no embedded dictionaries or arrays).
174174
*/
175-
public static void showExportWarningIfNeeded(@Nullable Context dialogContext) {
175+
private static void showExportWarningIfNeeded(@Nullable Context dialogContext) {
176176
Utils.verifyOnMainThread();
177177
initialize();
178178

@@ -245,11 +245,4 @@ public static void initialize() {
245245

246246
SegmentCategory.updateEnabledCategories();
247247
}
248-
249-
/**
250-
* Updates internal data based on {@link Setting} values.
251-
*/
252-
public static void updateFromImportedSettings() {
253-
SegmentCategory.loadAllCategoriesFromSettings();
254-
}
255248
}

0 commit comments

Comments
 (0)