mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Add support for poToken and visitor data
Fixes api requests https://github.com/iv-org/invidious/pull/4789
This commit is contained in:
parent
d2df5cef98
commit
090e185765
3 changed files with 22 additions and 4 deletions
|
@ -195,7 +195,12 @@ addDefaults(config, {
|
||||||
useCacheForSegmentGroups: false,
|
useCacheForSegmentGroups: false,
|
||||||
maxConnections: 100,
|
maxConnections: 100,
|
||||||
maxResponseTime: 1000,
|
maxResponseTime: 1000,
|
||||||
maxResponseTimeWhileLoadingCache: 2000
|
maxResponseTimeWhileLoadingCache: 2000,
|
||||||
|
etagExpiry: 5000,
|
||||||
|
youTubeKeys: {
|
||||||
|
visitorData: null,
|
||||||
|
poToken: null
|
||||||
|
}
|
||||||
});
|
});
|
||||||
loadFromEnv(config);
|
loadFromEnv(config);
|
||||||
migrate(config);
|
migrate(config);
|
||||||
|
|
|
@ -109,6 +109,11 @@ export interface SBSConfig {
|
||||||
maxConnections: number;
|
maxConnections: number;
|
||||||
maxResponseTime: number;
|
maxResponseTime: number;
|
||||||
maxResponseTimeWhileLoadingCache: number;
|
maxResponseTimeWhileLoadingCache: number;
|
||||||
|
etagExpiry: number;
|
||||||
|
youTubeKeys: {
|
||||||
|
visitorData: string | null;
|
||||||
|
poToken: string | null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhookConfig {
|
export interface WebhookConfig {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import axios from "axios";
|
||||||
import { Logger } from "./logger";
|
import { Logger } from "./logger";
|
||||||
import { innerTubeVideoDetails } from "../types/innerTubeApi.model";
|
import { innerTubeVideoDetails } from "../types/innerTubeApi.model";
|
||||||
import DiskCache from "./diskCache";
|
import DiskCache from "./diskCache";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
const privateResponse = (videoId: string, reason: string): innerTubeVideoDetails => ({
|
const privateResponse = (videoId: string, reason: string): innerTubeVideoDetails => ({
|
||||||
videoId,
|
videoId,
|
||||||
|
@ -34,13 +35,20 @@ export async function getFromITube (videoID: string): Promise<innerTubeVideoDeta
|
||||||
context: {
|
context: {
|
||||||
client: {
|
client: {
|
||||||
clientName: "WEB",
|
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, {
|
const result = await axios.post(url, data, {
|
||||||
timeout: 3500
|
timeout: 3500,
|
||||||
|
headers: {
|
||||||
|
"X-Goog-Visitor-Id": config.youTubeKeys.visitorData
|
||||||
|
}
|
||||||
});
|
});
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
|
|
Loading…
Reference in a new issue