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

Commit ea4b073

Browse files
fix(YouTube - Spoof video streams): Handle app left open for a long time (#709)
1 parent f82d293 commit ea4b073

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

app/src/main/java/app/revanced/integrations/youtube/patches/spoof/requests/StreamingDataRequest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public class StreamingDataRequest {
5353
}
5454
}
5555

56+
private static final String[] REQUEST_HEADER_KEYS = {
57+
"Authorization", // Available only to logged in users.
58+
"X-GOOG-API-FORMAT-VERSION",
59+
"X-Goog-Visitor-Id"
60+
};
61+
5662
/**
5763
* TCP connection and HTTP read timeout.
5864
*/
@@ -112,10 +118,12 @@ private static HttpURLConnection send(ClientType clientType, String videoId,
112118
connection.setConnectTimeout(HTTP_TIMEOUT_MILLISECONDS);
113119
connection.setReadTimeout(HTTP_TIMEOUT_MILLISECONDS);
114120

115-
String authHeader = playerHeaders.get("Authorization");
116-
String visitorId = playerHeaders.get("X-Goog-Visitor-Id");
117-
connection.setRequestProperty("Authorization", authHeader);
118-
connection.setRequestProperty("X-Goog-Visitor-Id", visitorId);
121+
for (String key : REQUEST_HEADER_KEYS) {
122+
String value = playerHeaders.get(key);
123+
if (value != null) {
124+
connection.setRequestProperty(key, value);
125+
}
126+
}
119127

120128
String innerTubeBody = String.format(PlayerRoutes.createInnertubeBody(clientType), videoId);
121129
byte[] requestBody = innerTubeBody.getBytes(StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)