Skip to content

Commit

Permalink
Add support for floatie proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Nov 4, 2024
1 parent b03057c commit 826d49b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ addDefaults(config, {
etagExpiry: 5000,
youTubeKeys: {
visitorData: null,
poToken: null
poToken: null,
floatieUrl: null,
floatieAuth: null
}
});
loadFromEnv(config);
Expand Down
2 changes: 2 additions & 0 deletions src/types/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export interface SBSConfig {
youTubeKeys: {
visitorData: string | null;
poToken: string | null;
floatieUrl: string | null;
floatieAuth: string | null;
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/utils/innerTubeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 826d49b

Please sign in to comment.