From 090e185765c80b8f88b70fbfa67e29f2d38cdb8e Mon Sep 17 00:00:00 2001 From: Ajay Date: Mon, 12 Aug 2024 00:33:11 -0400 Subject: [PATCH] Add support for poToken and visitor data Fixes api requests https://github.com/iv-org/invidious/pull/4789 --- src/config.ts | 7 ++++++- src/types/config.model.ts | 5 +++++ src/utils/innerTubeAPI.ts | 14 +++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 83e2fa1..ce6265e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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); diff --git a/src/types/config.model.ts b/src/types/config.model.ts index da33810..43041cc 100644 --- a/src/types/config.model.ts +++ b/src/types/config.model.ts @@ -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 { diff --git a/src/utils/innerTubeAPI.ts b/src/utils/innerTubeAPI.ts index 1d75ccc..be7cd9e 100644 --- a/src/utils/innerTubeAPI.ts +++ b/src/utils/innerTubeAPI.ts @@ -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