Add support for floatie proxy

This commit is contained in:
Ajay
2024-11-04 15:04:43 -05:00
parent b03057c5bf
commit 826d49ba1f
3 changed files with 22 additions and 1 deletions

View File

@@ -201,7 +201,9 @@ addDefaults(config, {
etagExpiry: 5000,
youTubeKeys: {
visitorData: null,
poToken: null
poToken: null,
floatieUrl: null,
floatieAuth: null
}
});
loadFromEnv(config);

View File

@@ -115,6 +115,8 @@ export interface SBSConfig {
youTubeKeys: {
visitorData: string | null;
poToken: string | null;
floatieUrl: string | null;
floatieAuth: string | null;
}
}

View File

@@ -29,6 +29,23 @@ const privateResponse = (videoId: string, reason: string): innerTubeVideoDetails
});
export async function getFromITube (videoID: string): Promise<innerTubeVideoDetails> {
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 = {