Skip to content

Commit c3423bb

Browse files
fix(YouTube - Spoof video streams): Ignore harmless error toast if hide ads is disabled
1 parent 519d57c commit c3423bb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,25 @@ public static void fetchStreams(String url, Map<String, String> requestHeaders)
115115
try {
116116
Uri uri = Uri.parse(url);
117117
String path = uri.getPath();
118+
if (path == null || !path.contains("player")) {
119+
return;
120+
}
118121

119122
// 'heartbeat' has no video id and appears to be only after playback has started.
120123
// 'refresh' has no video id and appears to happen when waiting for a livestream to start.
121-
if (path != null && path.contains("player") && !path.contains("heartbeat")
122-
&& !path.contains("refresh")) {
123-
String id = uri.getQueryParameter("id");
124-
if (id == null) {
125-
Logger.printException(() -> "Ignoring request that has no video id." +
126-
" Url: " + url + " headers: " + requestHeaders);
127-
return;
128-
}
124+
// 'ad_break' has no video id.
125+
if (path.contains("heartbeat") || path.contains("refresh") || path.contains("ad_break")) {
126+
Logger.printDebug(() -> "Ignoring path: " + path);
127+
return;
128+
}
129129

130-
StreamingDataRequest.fetchRequest(id, requestHeaders);
130+
String id = uri.getQueryParameter("id");
131+
if (id == null) {
132+
Logger.printException(() -> "Ignoring request with no id. Url: " + url);
133+
return;
131134
}
135+
136+
StreamingDataRequest.fetchRequest(id, requestHeaders);
132137
} catch (Exception ex) {
133138
Logger.printException(() -> "buildRequest failure", ex);
134139
}

0 commit comments

Comments
 (0)