diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt new file mode 100644 index 000000000..f0c659bcd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.video.livestream.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object OrganicPlaybackContextModelFingerprint : MethodFingerprint( + returnType = "V", + strings = listOf("Null contentCpn") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt new file mode 100644 index 000000000..59f983cc2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.youtube.video.livestream.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.video.livestream.fingerprints.OrganicPlaybackContextModelFingerprint +import app.revanced.util.integrations.Constants.VIDEO_PATH + +@Name("live-stream-speed") +@YouTubeCompatibility +@Version("0.0.1") +class LiveStreamPatch : BytecodePatch( + listOf( + OrganicPlaybackContextModelFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + OrganicPlaybackContextModelFingerprint.result?.mutableMethod?.addInstruction( + 2, + "invoke-static { p2 }, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->liveStreamObserver(Z)V" + ) ?: return OrganicPlaybackContextModelFingerprint.toErrorResult() + + return PatchResultSuccess() + } + + private companion object { + const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR = + "$VIDEO_PATH/VideoSpeedPatch;" + } + +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt index b7347b1b9..bf926a7e7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt @@ -14,6 +14,7 @@ import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.Vid import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch +import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.* import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.VIDEO_PATH @@ -23,6 +24,7 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @DependsOn( [ LegacyVideoIdPatch::class, + LiveStreamPatch::class, OverrideSpeedHookPatch::class, SharedResourceIdPatch::class ] @@ -64,6 +66,5 @@ class VideoSpeedBytecodePatch : BytecodePatch( private companion object { const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoSpeedPatch;" - var insertIndex: Int = 0 } } \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index bf4035b25..8bd56e983 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -101,6 +101,9 @@ Is it ready to submit?" Default video quality Cellular Default video quality Wi-Fi Default video speed + Default video speed is enabled in live stream + Default video speed is disabled in live stream + Disable default video speed in live stream Chapters haptic feedback is enabled Chapters haptic feedback is disabled Disable chapters haptic feedback diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index cc9dd2a3a..aa6c26dad 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -388,6 +388,9 @@ + +