fix(YouTube - Spoof video streams): Handle app left open for a long time (#709)

This commit is contained in:
LisoUseInAIKyrios 2024-10-03 19:22:30 -04:00 committed by GitHub
parent f82d29378d
commit ea4b073f5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,6 +53,12 @@ public class StreamingDataRequest {
} }
} }
private static final String[] REQUEST_HEADER_KEYS = {
"Authorization", // Available only to logged in users.
"X-GOOG-API-FORMAT-VERSION",
"X-Goog-Visitor-Id"
};
/** /**
* TCP connection and HTTP read timeout. * TCP connection and HTTP read timeout.
*/ */
@ -112,10 +118,12 @@ public class StreamingDataRequest {
connection.setConnectTimeout(HTTP_TIMEOUT_MILLISECONDS); connection.setConnectTimeout(HTTP_TIMEOUT_MILLISECONDS);
connection.setReadTimeout(HTTP_TIMEOUT_MILLISECONDS); connection.setReadTimeout(HTTP_TIMEOUT_MILLISECONDS);
String authHeader = playerHeaders.get("Authorization"); for (String key : REQUEST_HEADER_KEYS) {
String visitorId = playerHeaders.get("X-Goog-Visitor-Id"); String value = playerHeaders.get(key);
connection.setRequestProperty("Authorization", authHeader); if (value != null) {
connection.setRequestProperty("X-Goog-Visitor-Id", visitorId); connection.setRequestProperty(key, value);
}
}
String innerTubeBody = String.format(PlayerRoutes.createInnertubeBody(clientType), videoId); String innerTubeBody = String.format(PlayerRoutes.createInnertubeBody(clientType), videoId);
byte[] requestBody = innerTubeBody.getBytes(StandardCharsets.UTF_8); byte[] requestBody = innerTubeBody.getBytes(StandardCharsets.UTF_8);