generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Force original audio
patch (#4122)
- Loading branch information
1 parent
1e18634
commit f4aa440
Showing
14 changed files
with
297 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...youtube/src/main/java/app/revanced/extension/youtube/patches/ForceOriginalAudioPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.revanced.extension.youtube.patches; | ||
|
||
import app.revanced.extension.shared.Logger; | ||
import app.revanced.extension.youtube.settings.Settings; | ||
|
||
@SuppressWarnings("unused") | ||
public class ForceOriginalAudioPatch { | ||
|
||
private static final String DEFAULT_AUDIO_TRACKS_IDENTIFIER = "original"; | ||
|
||
/** | ||
* Injection point. | ||
*/ | ||
public static boolean isDefaultAudioStream(boolean isDefault, String audioTrackId, String audioTrackDisplayName) { | ||
try { | ||
if (!Settings.FORCE_ORIGINAL_AUDIO.get()) { | ||
return isDefault; | ||
} | ||
|
||
if (audioTrackDisplayName.isEmpty()) { | ||
// Older app targets can have empty audio tracks and these might be placeholders. | ||
// The real audio tracks are called after these. | ||
return isDefault; | ||
} | ||
|
||
Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: " | ||
+ String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName); | ||
|
||
final boolean isOriginal = audioTrackDisplayName.contains(DEFAULT_AUDIO_TRACKS_IDENTIFIER); | ||
if (isOriginal) { | ||
Logger.printDebug(() -> "Using audio: " + audioTrackId); | ||
} | ||
|
||
return isOriginal; | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "isDefaultAudioStream failure", ex); | ||
} | ||
|
||
return isDefault; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
patches/src/main/kotlin/app/revanced/patches/music/misc/spoof/SpoofVideoStreamsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
package app.revanced.patches.music.misc.spoof | ||
|
||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patches.music.misc.gms.musicActivityOnCreateFingerprint | ||
import app.revanced.patches.shared.misc.spoof.EXTENSION_CLASS_DESCRIPTOR | ||
import app.revanced.patches.shared.misc.spoof.spoofVideoStreamsPatch | ||
|
||
val spoofVideoStreamsPatch = spoofVideoStreamsPatch({ | ||
compatibleWith("com.google.android.apps.youtube.music") | ||
}, { | ||
musicActivityOnCreateFingerprint.method.addInstruction( | ||
0, | ||
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->setClientTypeToAndroidVrNoHl()V" | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/Fingerprints.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app.revanced.patches.youtube.video.audio | ||
|
||
import app.revanced.patcher.fingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
internal val streamingModelBuilderFingerprint = fingerprint { | ||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) | ||
returns("L") | ||
strings("vprng") | ||
} | ||
|
||
internal val menuItemAudioTrackFingerprint = fingerprint { | ||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) | ||
parameters("L") | ||
returns("V") | ||
strings("menu_item_audio_track") | ||
} | ||
|
||
internal val audioStreamingTypeSelector = fingerprint { | ||
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) | ||
returns("L") | ||
strings("raw") // String is not unique | ||
} |
Oops, something went wrong.