Skip to content

Commit

Permalink
fix(YouTube - ReturnYouTubeDislike): Fix RYD prefetching home feed Sh…
Browse files Browse the repository at this point in the history
…orts (#3195)
  • Loading branch information
LisoUseInAIKyrios committed Oct 24, 2023
1 parent d046e72 commit f3726fe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
VideoIdPatch.hookVideoId("$INTEGRATIONS_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V")

// Hook the player response video id, to start loading RYD sooner in the background.
VideoIdPatch.hookPlayerResponseVideoId("$INTEGRATIONS_CLASS_DESCRIPTOR->preloadVideoId(Ljava/lang/String;)V")
VideoIdPatch.hookPlayerResponseVideoId("$INTEGRATIONS_CLASS_DESCRIPTOR->preloadVideoId(Ljava/lang/String;Z)V")

// endregion

Expand Down Expand Up @@ -184,7 +184,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)

// Player response video id is needed to search for the video ids in Shorts litho components.
VideoIdPatch.hookPlayerResponseVideoId("$FILTER_CLASS_DESCRIPTOR->newPlayerResponseVideoId(Ljava/lang/String;)V")
VideoIdPatch.hookPlayerResponseVideoId("$FILTER_CLASS_DESCRIPTOR->newPlayerResponseVideoId(Ljava/lang/String;Z)V")

// endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ object VideoInformationPatch : BytecodePatch(
VideoIdPatch.hookVideoId(videoIdMethodDescriptor)
VideoIdPatch.hookBackgroundPlayVideoId(videoIdMethodDescriptor)
VideoIdPatch.hookPlayerResponseVideoId(
"$INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerResponseVideoId(Ljava/lang/String;)V")
"$INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerResponseVideoId(Ljava/lang/String;Z)V")

/*
* Set the video time method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ object PlayerResponseMethodHookPatch :
Closeable,
MutableSet<PlayerResponseMethodHookPatch.Hook> by mutableSetOf() {
private const val VIDEO_ID_PARAMETER = 1
private const val VIDEO_IS_OPENING_OR_PLAYING_PARAMETER = 11
private const val PROTO_BUFFER_PARAMETER_PARAMETER = 3

private lateinit var playerResponseMethod: MutableMethod
Expand All @@ -30,7 +31,7 @@ object PlayerResponseMethodHookPatch :

override fun close() {
fun hookVideoId(hook: Hook) = playerResponseMethod.addInstruction(
0, "invoke-static {p$VIDEO_ID_PARAMETER}, $hook"
0, "invoke-static {p$VIDEO_ID_PARAMETER, p$VIDEO_IS_OPENING_OR_PLAYING_PARAMETER}, $hook"
)

fun hookProtoBufferParameter(hook: Hook) = playerResponseMethod.addInstructions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object PlayerParameterBuilderFingerprint : MethodFingerprint(
"Ljava/lang/String;",
"Ljava/lang/String;",
"L",
"Z",
"Z", // Appears to indicate if the video id is being opened or is currently playing.
"Z",
"Z"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ object VideoIdPatch : BytecodePatch(
* Hooks the video id of every video when loaded.
* Supports all videos and functions in all situations.
*
* First parameter is the video id.
* Second parameter is if the video is being opened or is currently playing.
*
* Hook is always called off the main thread.
*
* This hook is called as soon as the player response is parsed,
Expand All @@ -117,7 +120,7 @@ object VideoIdPatch : BytecodePatch(
*
* Be aware, this can be called multiple times for the same video id.
*
* @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;`
* @param methodDescriptor which method to call. Params must be `Ljava/lang/String;Z`
*/
fun hookPlayerResponseVideoId(methodDescriptor: String) {
PlayerResponseMethodHookPatch += PlayerResponseMethodHookPatch.Hook.VideoId(
Expand Down

0 comments on commit f3726fe

Please sign in to comment.