Skip to content

Commit

Permalink
Add support for poToken and visitor data
Browse files Browse the repository at this point in the history
Fixes api requests

iv-org/invidious#4789
  • Loading branch information
ajayyy committed Aug 12, 2024
1 parent d2df5ce commit 090e185
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/types/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 11 additions & 3 deletions src/utils/innerTubeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 090e185

Please sign in to comment.