add hash requriment for ryd :3

This commit is contained in:
Ashley 2023-09-27 18:51:45 +00:00
parent 1154824a21
commit 85db2f4d84

View file

@ -30,7 +30,7 @@ const URL_WHITELIST = [
"vid.puffyan.us",
"invidious.lidarshield.cloud",
"invidious.epicsite.xyz",
"invidious.esmailelbob.xyz"
"invidious.esmailelbob.xyz",
];
const app = express();
@ -90,15 +90,14 @@ const listener = (req, res) => {
};
app.get("/", (req, res) => {
var json = {
status: "200",
version: "1.0.0",
URL_WHITELIST,
cache: "max-age-1848",
}
};
res.json(json)
res.json(json);
});
const apiUrl = "https://returnyoutubedislikeapi.com/votes?videoId=";
@ -106,8 +105,8 @@ const apiUrl = "https://returnyoutubedislikeapi.com/votes?videoId=";
// Define a cache object
const cache = {};
app.get('/api', async (req, res) => {
app.get("/api", async (req, res) => {
if (req.query.hash && req.query.hash === "d0550b6e28c8f93533a569c314d5b4e2") {
try {
const cacheKey = req.query.v;
@ -120,23 +119,23 @@ try {
}
// If the result is not cached or is older than 1 hour, fetch it from the API
const engagement = await fetch(apiUrl + req.query.v).then((res) => res.json());
const engagement = await fetch(apiUrl + req.query.v).then((res) =>
res.json()
);
// Cache the result for future requests
cache[cacheKey] = {
data: engagement,
timestamp: Date.now()
timestamp: Date.now(),
};
res.json({ data: engagement, cachedDate: new Date() });
} catch {
} catch {}
} else {
return res.send("no hash query found");
}
});
app.all("/*", listener);
app.listen(3000, () => console.log("Listening on 0.0.0.0:3000"));