fix(YouTube - Force original audio): Use correct original audio stream if app language is not English

This commit is contained in:
LisoUseInAIKyrios 2024-12-20 20:26:17 +04:00
parent f342e26997
commit 0d2017133e

View File

@ -6,7 +6,7 @@ import app.revanced.extension.youtube.settings.Settings;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class ForceOriginalAudioPatch { public class ForceOriginalAudioPatch {
private static final String DEFAULT_AUDIO_TRACKS_IDENTIFIER = "original"; private static final String DEFAULT_AUDIO_TRACKS_SUFFIX = ".4";
/** /**
* Injection point. * Injection point.
@ -17,7 +17,7 @@ public class ForceOriginalAudioPatch {
return isDefault; return isDefault;
} }
if (audioTrackDisplayName.isEmpty()) { if (audioTrackId.isEmpty()) {
// Older app targets can have empty audio tracks and these might be placeholders. // Older app targets can have empty audio tracks and these might be placeholders.
// The real audio tracks are called after these. // The real audio tracks are called after these.
return isDefault; return isDefault;
@ -26,7 +26,7 @@ public class ForceOriginalAudioPatch {
Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: " Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: "
+ String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName); + String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName);
final boolean isOriginal = audioTrackDisplayName.contains(DEFAULT_AUDIO_TRACKS_IDENTIFIER); final boolean isOriginal = audioTrackId.endsWith(DEFAULT_AUDIO_TRACKS_SUFFIX);
if (isOriginal) { if (isOriginal) {
Logger.printDebug(() -> "Using audio: " + audioTrackId); Logger.printDebug(() -> "Using audio: " + audioTrackId);
} }