Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: Simplify fetch request hook
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Sep 10, 2024
1 parent 6df5f07 commit 69f0314
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import androidx.annotation.Nullable;

import org.chromium.net.UrlRequest;

import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -93,28 +91,25 @@ public static boolean isSpoofingEnabled() {
/**
* Injection point.
*/
public static UrlRequest buildRequest(UrlRequest.Builder builder, String url,
Map<String, String> playerHeaders) {
public static void fetchStreams(String url, Map<String, String> requestHeaders) {
if (SPOOF_STREAMING_DATA) {
try {
Uri uri = Uri.parse(url);
String path = uri.getPath();
if (path != null && path.contains("player") && !path.contains("heartbeat")) {
String videoId = Objects.requireNonNull(uri.getQueryParameter("id"));
StreamingDataRequest.fetchRequest(videoId, playerHeaders);
StreamingDataRequest.fetchRequest(videoId, requestHeaders);
}
} catch (Exception ex) {
Logger.printException(() -> "buildRequest failure", ex);
}
}

return builder.build();
}

/**
* Injection point.
* Fix playback by replace the streaming data.
* Called after {@link #buildRequest(UrlRequest.Builder, String, Map)}.
* Called after {@link #fetchStreams(String, Map)}.
*/
@Nullable
public static ByteBuffer getStreamingData(String videoId) {
Expand Down

0 comments on commit 69f0314

Please sign in to comment.