From c3423bb9e531cfa52f6d28e0b98bbe8ab8684c30 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 28 Dec 2024 01:10:01 +0400 Subject: [PATCH] fix(YouTube - Spoof video streams): Ignore harmless error toast if hide ads is disabled --- .../shared/spoof/SpoofVideoStreamsPatch.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java index ef11885da3..f2c0df9250 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java @@ -115,20 +115,25 @@ public static void fetchStreams(String url, Map requestHeaders) try { Uri uri = Uri.parse(url); String path = uri.getPath(); + if (path == null || !path.contains("player")) { + return; + } // 'heartbeat' has no video id and appears to be only after playback has started. // 'refresh' has no video id and appears to happen when waiting for a livestream to start. - if (path != null && path.contains("player") && !path.contains("heartbeat") - && !path.contains("refresh")) { - String id = uri.getQueryParameter("id"); - if (id == null) { - Logger.printException(() -> "Ignoring request that has no video id." + - " Url: " + url + " headers: " + requestHeaders); - return; - } + // 'ad_break' has no video id. + if (path.contains("heartbeat") || path.contains("refresh") || path.contains("ad_break")) { + Logger.printDebug(() -> "Ignoring path: " + path); + return; + } - StreamingDataRequest.fetchRequest(id, requestHeaders); + String id = uri.getQueryParameter("id"); + if (id == null) { + Logger.printException(() -> "Ignoring request with no id. Url: " + url); + return; } + + StreamingDataRequest.fetchRequest(id, requestHeaders); } catch (Exception ex) { Logger.printException(() -> "buildRequest failure", ex); }