Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YouTube - Spoof video streams): Use system language as default iOS audio stream #4042

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public static boolean importFromJSON(@NonNull Context alertDialogContext, @NonNu
}

for (ImportExportCallback callback : importExportCallbacks) {
callback.settingsExported(alertDialogContext);
callback.settingsImported(alertDialogContext);
}

Utils.showToastLong(numberOfSettingsImported == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
builder.setNeutralButton(str("revanced_settings_import_copy"), (dialog, which) -> {
Utils.setClipboard(getEditText().getText().toString());
}).setPositiveButton(str("revanced_settings_import"), (dialog, which) -> {
importSettings(getEditText().getText().toString());
importSettings(builder.getContext(), getEditText().getText().toString());
});
} catch (Exception ex) {
Logger.printException(() -> "onPrepareDialogBuilder failure", ex);
}
}

private void importSettings(String replacementSettings) {
private void importSettings(Context context, String replacementSettings) {
try {
if (replacementSettings.equals(existingSettings)) {
return;
}
AbstractPreferenceFragment.settingImportInProgress = true;

final boolean rebootNeeded = Setting.importFromJSON(Utils.getContext(), replacementSettings);
final boolean rebootNeeded = Setting.importFromJSON(context, replacementSettings);
if (rebootNeeded) {
AbstractPreferenceFragment.showRestartDialog(getContext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.net.HttpURLConnection;

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.youtube.patches.spoof.ClientType;
Expand All @@ -24,6 +25,9 @@ final class PlayerRoutes {
*/
private static final int CONNECTION_TIMEOUT_MILLISECONDS = 10 * 1000; // 10 Seconds.

private static final String LOCALE_LANGUAGE = Utils.getContext().getResources()
.getConfiguration().locale.getLanguage();

private PlayerRoutes() {
}

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

JSONObject client = new JSONObject();
// Required to use correct default audio channel with iOS.
client.put("hl", LOCALE_LANGUAGE);
client.put("clientName", clientType.name());
client.put("clientVersion", clientType.clientVersion);
client.put("deviceModel", clientType.deviceModel);
client.put("osVersion", clientType.osVersion);
if (clientType.androidSdkVersion != null) {
client.put("androidSdkVersion", clientType.androidSdkVersion);
}

context.put("client", client);

innerTubeBody.put("context", context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SponsorBlockSettings {
public static final Setting.ImportExportCallback SB_IMPORT_EXPORT_CALLBACK = new Setting.ImportExportCallback() {
@Override
public void settingsImported(@Nullable Context context) {
updateFromImportedSettings();
SegmentCategory.loadAllCategoriesFromSettings();
}
@Override
public void settingsExported(@Nullable Context context) {
Expand Down Expand Up @@ -172,7 +172,7 @@ public static String exportDesktopSettings() {
/**
* Export the categories using flatten json (no embedded dictionaries or arrays).
*/
public static void showExportWarningIfNeeded(@Nullable Context dialogContext) {
private static void showExportWarningIfNeeded(@Nullable Context dialogContext) {
Utils.verifyOnMainThread();
initialize();

Expand Down Expand Up @@ -245,11 +245,4 @@ public static void initialize() {

SegmentCategory.updateEnabledCategories();
}

/**
* Updates internal data based on {@link Setting} values.
*/
public static void updateFromImportedSettings() {
SegmentCategory.loadAllCategoriesFromSettings();
}
}
Loading