[YouTube] Add ability to use the guide endpoint to get a visitorData

Some clients like TVHTML5 are not allowed on the visitor_id endpoint
(with this client, a 400 HTTP response is returned with a precondition
check failed error).

Also disable pretty printing for these requests, like we do for others.
pull/1272/head
AudricV 2025-01-31 11:23:58 +01:00 zatwierdzone przez Stypox
rodzic 862a607fc6
commit d08331dbcf
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4BDF1B40A49FDD23
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -1502,7 +1502,8 @@ public final class YoutubeParsingHelper {
@Nonnull final ContentCountry contentCountry,
@Nonnull final Map<String, List<String>> httpHeaders,
@Nonnull final String innerTubeDomain,
@Nullable final String embedUrl) throws IOException, ExtractionException {
@Nullable final String embedUrl,
final boolean useGuideEndpoint) throws IOException, ExtractionException {
final JsonBuilder<JsonObject> builder = prepareJsonBuilder(
localization, contentCountry, innertubeClientRequestInfo, embedUrl);
@ -1510,7 +1511,10 @@ public final class YoutubeParsingHelper {
.getBytes(StandardCharsets.UTF_8);
final String visitorData = JsonUtils.toJsonObject(getValidJsonResponseBody(getDownloader()
.postWithContentTypeJson(innerTubeDomain + "visitor_id", httpHeaders, body)))
.postWithContentTypeJson(
innerTubeDomain + (useGuideEndpoint ? "guide" : "visitor_id")
+ "?" + DISABLE_PRETTY_PRINT_PARAMETER,
httpHeaders, body)))
.getObject("responseContext")
.getString("visitorData");