From 240c597322a62586e5b8c6854c9156792240574b Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 15 Dec 2024 00:12:42 +0400 Subject: [PATCH] refactor --- .../patches/ChangeDefaultAudioLanguagePatch.java | 12 ++++++------ .../video/audio/ChangeDefaultAudioLanguagePatch.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ChangeDefaultAudioLanguagePatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ChangeDefaultAudioLanguagePatch.java index 88330139f2..bb223dfeee 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ChangeDefaultAudioLanguagePatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ChangeDefaultAudioLanguagePatch.java @@ -20,7 +20,7 @@ public class ChangeDefaultAudioLanguagePatch { * it.10 */ private static final Pattern AUDIO_TRACK_ID_PATTERN = - Pattern.compile("^([a-z]{2})(-[A-Z]{2})?(\\.\\d+)"); + Pattern.compile("^([a-z]{2})(-[A-Z]{2})?.*"); /** * Injection point. @@ -38,13 +38,13 @@ public static boolean isAudioStreamAsDefault(boolean isDefault, String audioTrac return isDefault; // Do nothing. } - Logger.printDebug(() -> "isDefault: " + String.format("%-5s", isDefault) + " audioTrackId: " - + audioTrackId + " audioTrackDisplayName:" + audioTrackDisplayName); + Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: " + + String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName); if (defaultLanguage == AudioStreamLanguage.ORIGINAL) { final boolean isOriginal = audioTrackDisplayName.contains(DEFAULT_AUDIO_TRACKS_IDENTIFIER); if (isOriginal) { - Logger.printDebug(() -> "Using original audio language: " + audioTrackId); + Logger.printDebug(() -> "Using audio: " + audioTrackId); } return isOriginal; @@ -59,11 +59,11 @@ public static boolean isAudioStreamAsDefault(boolean isDefault, String audioTrac String desiredIso639 = defaultLanguage.getIso639_1(); if (desiredIso639.equals(matcher.group(1)) || desiredIso639.equals(matcher.group(2))) { - Logger.printDebug(() -> "Using preferred audio language: " + audioTrackId); + Logger.printDebug(() -> "Using audio: " + audioTrackId); return true; } } catch (Exception ex) { - Logger.printException(() -> "setAudioStreamAsDefault failure", ex); + Logger.printException(() -> "isAudioStreamAsDefault failure", ex); } return isDefault; diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ChangeDefaultAudioLanguagePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ChangeDefaultAudioLanguagePatch.kt index 0b19ada202..16e23eb400 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ChangeDefaultAudioLanguagePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ChangeDefaultAudioLanguagePatch.kt @@ -96,7 +96,7 @@ val changeDefaultAudioLanguagePatch = bytecodePatch( // Boolean is a 100% immutable class (all fields are final) // and safe to write to a shared field without volatile/synchronization, // but without volatile the field can show stale data - // and it's calculated by more than one thread. + // and the same field is calculated more than once by different threads. AccessFlags.PRIVATE.value or AccessFlags.VOLATILE.value, null, null,