deduplicate requests
Some checks are pending
ci / build (push) Waiting to run
ci / test (push) Waiting to run

This commit is contained in:
CJ_Clippy 2025-08-25 12:19:36 -08:00
parent 8a7baefd76
commit 46a9041b97
4 changed files with 38 additions and 21 deletions

View File

@ -37,8 +37,6 @@ jobs:
labels: | labels: |
org.opencontainers.image.description=The Galaxy's Best VTuber hentai site org.opencontainers.image.description=The Galaxy's Best VTuber hentai site
org.opencontainers.image.title=our org.opencontainers.image.title=our
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
org.opencontainers.image.version={{version}}
org.opencontainers.image.licenses=unlicense org.opencontainers.image.licenses=unlicense
org.opencontainers.image.source=https://gitea.futureporn.net/futureporn/fp org.opencontainers.image.source=https://gitea.futureporn.net/futureporn/fp
org.opencontainers.image.url=https://gitea.futureporn.net/futureporn/-/packages/container/our org.opencontainers.image.url=https://gitea.futureporn.net/futureporn/-/packages/container/our

View File

@ -2,24 +2,27 @@
#! /usr/local/bin/abs #! /usr/local/bin/abs
echo(" * Remux the .ts to .mp4 ") echo(" * Remux the .ts to .mp4 using `ffmpeg -i 2025-08-25T00-12-24Z.ts -c copy projektmelody-chaturbate-2025-08-24.mp4")
echo(" [Press Enter When Complete...]") echo(" [Press Enter When Complete...]")
_ = stdin() _ = stdin()
echo(" * Temporarily serve the mp4 using `npx http-server ./serve` ")
echo(" [Press Enter When Complete...]")
_ = stdin()
echo(" * Generate a thumbnail -- bash <(curl -fsSL https://gitea.futureporn.net/futureporn/fp/raw/branch/main/packages/scripts/thumbnail-generator.sh) ./projektmelody-chaturbate-2025-02-12.mp4")
echo(" * Upload the .mp4 to Mux ")
echo(" * Upload the .mp4 to Backblaze ") echo(" * Upload the .mp4 to Backblaze ")
echo(" * Generate a thumbnail -- bash <(curl -fsSL https://gitea.futureporn.net/futureporn/fp/raw/branch/main/packages/scripts/thumbnail-generator.sh) ./projektmelody-chaturbate-2025-02-12.mp4")
echo(" * Upload the thumbnail to Backblaze")
echo(" [Press Enter When Complete...]")
_ = stdin()
echo(" * Upload the .mp4 to Mux ")
echo(" * Add the .mp4 to IPFS -- sudo -u ipfs ipfs add --cid-version=1 ./projektmelody-chaturbate-2025-02-12.mp4") echo(" * Add the .mp4 to IPFS -- sudo -u ipfs ipfs add --cid-version=1 ./projektmelody-chaturbate-2025-02-12.mp4")
echo(" * Remote pin the IPFS CID") echo(" * Remote pin the IPFS CID")
echo(" [Press Enter When Complete...]") echo(" [Press Enter When Complete...]")
_ = stdin() _ = stdin()
echo(" * Create magnet link. ex: `torf ~/Downloads/projektmelody-chaturbate-2025-08-25.mp4 --notorrent --notracker --webseed https://futureporn-b2.b-cdn.net/projektmelody-chaturbate-2025-08-25.mp4'")
echo(" [Press Enter When Complete...]")
_ = stdin()
echo(" * Create a B2 File (.mp4) in Strapi") echo(" * Create a B2 File (.mp4) in Strapi")
echo(" * Create a B2 File (thumbnail) in Strapi") echo(" * Create a B2 File (thumbnail) in Strapi")

View File

@ -2,4 +2,6 @@ pre-commit
ggshield ggshield
click click
ansible ansible
ansible-lint ansible-lint
vcsi
torrentfile

View File

@ -20,6 +20,8 @@ const cache = new TTLCache({
ttl: 30 * 60 * 1000, // 30 minutes ttl: 30 * 60 * 1000, // 30 minutes
}); });
const inflight = new Map();
// Format date as YYYY-MM-DD_HH:mm:ss_UTC // Format date as YYYY-MM-DD_HH:mm:ss_UTC
function formatTwitterDate(date) { function formatTwitterDate(date) {
const pad = (n) => String(n).padStart(2, "0"); const pad = (n) => String(n).padStart(2, "0");
@ -74,28 +76,40 @@ function buildFeed(username, tweets) {
fastify.get("/:username", async (request, reply) => { fastify.get("/:username", async (request, reply) => {
const { username } = request.params; const { username } = request.params;
const key = username.toLowerCase();
if (!env.WHITELIST.has(username.toLowerCase())) { if (!env.WHITELIST.has(key)) {
return reply.code(403).send({ error: "Forbidden username" }); return reply.code(403).send({ error: "Forbidden username" });
} }
// Serve from cache if exists // Serve from cache if exists
const cached = cache.get(username); const cached = cache.get(key);
if (cached) { if (cached) {
fastify.log.info('sending cached data'); fastify.log.info('sending cached data');
fastify.log.info(cached); return reply.header("Content-Type", "application/rss+xml").send(cached.xml);
return reply
.header("Content-Type", "application/rss+xml")
.send(cached.xml);
} }
const data = await getJson(username) let dataPromise;
const xml = buildFeed(username, data); if (inflight.has(key)) {
// Wait for the in-progress fetch
fastify.log.info('waiting for in-flight fetch');
dataPromise = inflight.get(key);
} else {
// Start a new fetch
dataPromise = getJson(key);
inflight.set(key, dataPromise);
// Ensure we remove from inflight map when done
dataPromise.finally(() => inflight.delete(key));
}
const data = await dataPromise;
const xml = buildFeed(key, data);
// Cache result // Cache result
cache.set(username, { xml, timestamp: Date.now() }); cache.set(key, { xml, timestamp: Date.now() });
return reply.header("Content-Type", "application/rss+xml").send(xml); return reply.header("Content-Type", "application/rss+xml").send(xml);
}); });