diff --git a/src/config.ts b/src/config.ts index cbd520d..35fb3db 100644 --- a/src/config.ts +++ b/src/config.ts @@ -201,7 +201,9 @@ addDefaults(config, { etagExpiry: 5000, youTubeKeys: { visitorData: null, - poToken: null + poToken: null, + floatieUrl: null, + floatieAuth: null } }); loadFromEnv(config); diff --git a/src/types/config.model.ts b/src/types/config.model.ts index 771188d..e8a7924 100644 --- a/src/types/config.model.ts +++ b/src/types/config.model.ts @@ -115,6 +115,8 @@ export interface SBSConfig { youTubeKeys: { visitorData: string | null; poToken: string | null; + floatieUrl: string | null; + floatieAuth: string | null; } } diff --git a/src/utils/innerTubeAPI.ts b/src/utils/innerTubeAPI.ts index be7cd9e..217651e 100644 --- a/src/utils/innerTubeAPI.ts +++ b/src/utils/innerTubeAPI.ts @@ -29,6 +29,23 @@ const privateResponse = (videoId: string, reason: string): innerTubeVideoDetails }); export async function getFromITube (videoID: string): Promise { + if (config.youTubeKeys.floatieUrl) { + const result = await axios.get(config.youTubeKeys.floatieUrl, { + params: { + videoID, + auth: config.youTubeKeys.floatieAuth + } + }); + + if (result.status === 200) { + return result.data?.videoDetails ?? privateResponse(videoID, result.data?.playabilityStatus?.reason ?? "Bad response"); + } else if (result.status === 500) { + return privateResponse(videoID, result.data ?? "Bad response"); + } else { + return Promise.reject(`Floatie returned non-200 response: ${result.status}`); + } + } + // start subrequest const url = "https://www.youtube.com/youtubei/v1/player"; const data = {