mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 23:17:57 +01:00
add cache for channels oowowowow :3
This commit is contained in:
parent
56d01efe6d
commit
340c2a4ce0
1 changed files with 39 additions and 24 deletions
|
@ -55,7 +55,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
.then((colors) => colors[0].hex()),
|
.then((colors) => colors[0].hex()),
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
res.redirect("/")
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
try {
|
try {
|
||||||
const ID = req.query.id;
|
const ID = req.query.id;
|
||||||
const tab = req.query.tab;
|
const tab = req.query.tab;
|
||||||
|
const cache = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// about
|
// about
|
||||||
|
@ -148,20 +149,34 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var tj = await getChannelData(
|
||||||
const tj = await getChannelData(
|
|
||||||
`https://invid-api.poketube.fun/api/v1/channels/videos/${ID}/?sort_by=${sort_by}${continuation}`
|
`https://invid-api.poketube.fun/api/v1/channels/videos/${ID}/?sort_by=${sort_by}${continuation}`
|
||||||
);
|
);
|
||||||
const shorts = await getChannelData(
|
var shorts = await getChannelData(
|
||||||
`https://invid-api.poketube.fun/api/v1/channels/${ID}/shorts?sort_by=${sort_by}${continuations}`
|
`https://invid-api.poketube.fun/api/v1/channels/${ID}/shorts?sort_by=${sort_by}${continuations}`
|
||||||
);
|
);
|
||||||
const stream = await getChannelData(
|
var stream = await getChannelData(
|
||||||
`https://invid-api.poketube.fun/api/v1/channels/${ID}/streams?sort_by=${sort_by}${continuationl}`
|
`https://invid-api.poketube.fun/api/v1/channels/${ID}/streams?sort_by=${sort_by}${continuationl}`
|
||||||
);
|
);
|
||||||
const c = await getChannelData(
|
var c = await getChannelData(
|
||||||
`https://invid-api.poketube.fun/api/v1/channels/community/${ID}/`
|
`https://invid-api.poketube.fun/api/v1/channels/community/${ID}/`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cache[ID] = {
|
||||||
|
result: {
|
||||||
|
tj,
|
||||||
|
shorts,
|
||||||
|
stream,
|
||||||
|
c,
|
||||||
|
boutJson,
|
||||||
|
},
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cache[ID] && Date.now() - cache[ID].timestamp < 3600000) {
|
||||||
|
var { tj, shorts, stream, c, boutJson } = cache[ID].result;
|
||||||
|
}
|
||||||
|
|
||||||
const summary = await wiki.summary(boutJson.Channel.Metadata.Name);
|
const summary = await wiki.summary(boutJson.Channel.Metadata.Name);
|
||||||
const wikiSummary = summary.title !== "Not found." ? summary : "none";
|
const wikiSummary = summary.title !== "Not found." ? summary : "none";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue