Add support for poToken and visitor data

Fixes api requests

https://github.com/iv-org/invidious/pull/4789
This commit is contained in:
Ajay 2024-08-12 00:33:11 -04:00
parent d2df5cef98
commit 090e185765
3 changed files with 22 additions and 4 deletions

View file

@ -195,7 +195,12 @@ addDefaults(config, {
useCacheForSegmentGroups: false,
maxConnections: 100,
maxResponseTime: 1000,
maxResponseTimeWhileLoadingCache: 2000
maxResponseTimeWhileLoadingCache: 2000,
etagExpiry: 5000,
youTubeKeys: {
visitorData: null,
poToken: null
}
});
loadFromEnv(config);
migrate(config);

View file

@ -109,6 +109,11 @@ export interface SBSConfig {
maxConnections: number;
maxResponseTime: number;
maxResponseTimeWhileLoadingCache: number;
etagExpiry: number;
youTubeKeys: {
visitorData: string | null;
poToken: string | null;
}
}
export interface WebhookConfig {

View file

@ -2,6 +2,7 @@ import axios from "axios";
import { Logger } from "./logger";
import { innerTubeVideoDetails } from "../types/innerTubeApi.model";
import DiskCache from "./diskCache";
import { config } from "../config";
const privateResponse = (videoId: string, reason: string): innerTubeVideoDetails => ({
videoId,
@ -34,13 +35,20 @@ export async function getFromITube (videoID: string): Promise<innerTubeVideoDeta
context: {
client: {
clientName: "WEB",
clientVersion: "2.20221215.04.01"
clientVersion: "2.20221215.04.01",
visitorData: config.youTubeKeys.visitorData
}
},
videoId: videoID
videoId: videoID,
serviceIntegrityDimensions: {
poToken: config.youTubeKeys.poToken
}
};
const result = await axios.post(url, data, {
timeout: 3500
timeout: 3500,
headers: {
"X-Goog-Visitor-Id": config.youTubeKeys.visitorData
}
});
/* istanbul ignore else */
if (result.status === 200) {