This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
Liam a5e00e4850
Some checks failed
Deploy Backend / deploy (push) Has been cancelled
Deploy Website / deploy (push) Failing after 2m19s
add leaderboard embed image
2024-10-16 02:27:59 +01:00

28 lines
774 B
TypeScript

import ky from "ky";
import { NotFoundError } from "../error/not-found-error";
const SCORESABER_REPLAY_ENDPOINT = "https://scoresaber.com/api/game/telemetry/downloadReplay";
export class ReplayService {
/**
* Gets the app statistics.
*/
public static async getReplay(playerId: string, leaderboardId: string) {
const response = await ky.get(SCORESABER_REPLAY_ENDPOINT, {
searchParams: {
playerId,
leaderboardId,
},
headers: {
"User-Agent": "ScoreSaber-PC/3.3.13",
},
});
const replayData = await response.arrayBuffer();
if (replayData === undefined) {
throw new NotFoundError(`Replay for player "${playerId}" and leaderboard "${leaderboardId}" not found`);
}
return replayData;
}
}