Skip to content
OkeyAmyPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

wallpapers.okeyamy.xyz

A self-updating anime wallpaper archive. A scheduled job pulls from curated sources daily, filters and re-encodes what it finds, extracts a colour palette from each image, and commits the result. Cloudflare Pages serves the repo as a static site — there is no server, no database, and no build step.

GitHub Actions (daily cron)
  └─ sync_danbooru.py   fetch → filter → dedupe → WebP → palette
  └─ prune.py           drop oldest entries once a free-tier ceiling is hit
  └─ build_site.py      manifest + JSON-LD + sitemap + robots + llms.txt + OG card
  └─ git push
        └─ Cloudflare Pages redeploys automatically

Layout

Path What it is
index.html The whole site. Static gallery is injected at build time.
assets/ Stylesheet, runtime, favicon, generated OG card
data/wallpapers.json Canonical index (dedupe hashes included); the pipeline and build read this
data/wallpapers.client.json Minified subset the frontend fetches — generated by build_site.py
wallpapers/ Processed WebP images — only in local mode; empty once storage is on R2
incoming/ Local drop zone for your own uploads (git-ignored)
scripts/ The pipeline
_headers, robots.txt, sitemap.xml, llms.txt Generated — edit build_site.py, not these

Storage

Images live in Cloudflare R2, not in git. The repository therefore holds only code and a JSON manifest and stays a few megabytes no matter how long the sync runs — which matters because deleting a file from git does not reclaim its history, so an image-in-repo archive grows forever.

Set these and the pipeline uses R2. Locally, leaving them unset falls back to writing into wallpapers/ so the project still runs with no cloud account — but the GitHub Actions workflow requires all five and fails its preflight check without them, rather than silently publishing a manifest that points at storage nothing was actually uploaded to:

R2_ACCOUNT_ID  R2_ACCESS_KEY_ID  R2_SECRET_ACCESS_KEY  R2_BUCKET
R2_PUBLIC_BASE   # public bucket URL, e.g. https://cdn.okeyamy.xyz

R2_PUBLIC_BASE also drives the img-src in the generated CSP, so the image host can never fall out of sync with the security policy.

Why this cannot exceed the free tier

prune.py runs before every build and drops the oldest entries once either ceiling is reached:

  • 8 GiB stored — under R2's 10 GB free allowance, with headroom
  • 4,000 items — well under Cloudflare Pages' 20,000-file deploy limit

R2 bills nothing for egress, so traffic alone can never generate a charge.

Ingest policy

Set in scripts/pipeline.py:

  • Minimum 1280×720; anything smaller is rejected
  • Long edge capped at 3840px
  • WebP quality 92 (full size), plus a 640px thumbnail; the download button writes a lossless PNG of that master. On iOS it opens the PNG full-screen for long-press → Save to Photos, since Safari downloads only reach Files.
  • Deduplicated by SHA-256 and by difference hash, so the same image reposted at a different size or JPEG quality is caught too
  • Rejected as a duplicate before anything is uploaded, not after — a content-addressed key means a duplicate would otherwise collide with the original's storage location
  • Crops and zooms of a picture already here are caught too (scripts/cropmatch.py: ORB feature matching with a geometric check). The fingerprint index is one file in R2 (index/features.npz), not in git; scripts/crop_index.py fills it from thumbnails before every sync
  • Anything removed by cull.py or prune.py is recorded in data/removed.json and never re-fetched, from any source
  • Danbooru queries are rating:general only

Wallhaven discovery

Wallhaven's generic toplist only reaches one year back, so it is shallow and quickly absorbed. scripts/anime_series.py keeps a catalogue of anime titles from AniList (free, keyless; the top 1,000 by popularity, merged by franchise) and refreshes it weekly. Each sync rotates through a few of them — plus one currently airing show and one game/classic seed such as Genshin Impact or Sailor Moon — and searches all-time by views. That is much deeper than the toplist: Bleach is 68 results in the last year but 864 all-time, Hunter x Hunter 5 vs 263, Inuyasha 0 vs 56.

Pages advance by themselves: once every result on a page is archived or in the reject ledger, the next visit walks one page deeper, so a 36-page series keeps yielding without a cursor file. Wallhaven ids already in the archive are skipped before the detail call, so a crossover wallpaper is not downloaded once per series it is tagged with.

The catalogue is committed, so the sync does not depend on AniList at run time. If the weekly refresh fails, the previous list is used; if there has never been one, the generic axes still run.

Adding your own wallpapers

Drop image files into incoming/ and run scripts/ingest_local.py. To credit wherever an image actually came from, add a same-named .source sidecar:

incoming/nice.png
incoming/nice.png.source
https://twitter.com/artist/status/12345
artist_handle
Ganyu standing in the snow

Line 1 is the source link, line 2 is the artist/handle (optional), line 3 is a title (optional). Both files are consumed on ingest — the sidecar is deleted along with the source image once its contents are written into the item's permalink/author/title fields.

The title is worth writing. It becomes the image's alt text and the name it is indexed under, and an image with no title is deliberately left untitled rather than named after its file — IMG-20260810-WA0002 describes nothing. Naming the subject puts it on that character's page:

python scripts/ingest_local.py --title "Ganyu in the snow" --character Ganyu

Both flags apply to every image in the batch; a .source sidecar wins over --title for the image it belongs to. scripts/build_site.py prints a count of items it could not describe, so a missing title shows up at build time rather than in a search result months later.

Character pages

build_site.py writes one page per character into w/, served at /w/<character>, for every character with at least MIN_HUB_ITEMS wallpapers (2). Characters below the line still appear on the homepage and in the image sitemap — they just don't get a page whose only content is a single image.

scripts/backfill_metadata.py is a one-off that repaired the titles and character tags of items ingested before any of this existed. It has already been run; it is kept because it is idempotent and documents what was wrong.

Deploying

Static egress on Cloudflare Pages is unmetered, which matters because a wallpaper site's entire cost is bandwidth.

  1. Push this repo to GitHub (public — Actions minutes are unlimited on public repos).
  2. R2 → Create bucket. Add an R2 API token (Object Read & Write) and set the five R2_* values as repository secrets.
  3. Give the bucket a public URL: either enable its r2.dev domain or attach a custom one such as cdn.okeyamy.xyz. That value is R2_PUBLIC_BASE.
  4. Cloudflare Pages → Create project → connect the repo. Build command: none. Output directory: /.
  5. Custom domain → wallpapers.okeyamy.xyz.

Anti-scraping

robots.txt welcomes search and AI crawlers (that is the point — discovery) while keeping generic bots out of the image directories. That is advisory only, so the actual defence is at the edge — in the Cloudflare dashboard:

  • Security → Bots → enable Bot Fight Mode
  • Security → WAF → Rate limiting rules → add a rule on http.request.uri.path contains "/wallpapers/", e.g. 60 requests per minute per IP, action Block

That breaks the sequential crawl pattern used to clone a whole gallery without affecting anyone browsing normally.

Publish safety

The manifest in the last commit is the last known good set. The scheduled jobs treat it as a floor, not a suggestion:

  • A sync that accepts nothing returns before touching the manifest, so an all-rejected day — or a source returning zero posts — leaves the live site byte-identical.
  • scripts/publish_guard.py runs after the build and before git commit. It compares the committed manifest with the one this run produced. Additions always pass; a shrink passes only by the number prune.py or cull.py explicitly reported as deleted; a non-empty archive can never be replaced by an empty one. Anything else — a corrupt read, a partial write, a bug — stops the job while the previous deploy keeps serving.
  • git revert <sha> is the rollback. There is no snapshot file, because git already stores every published set.

A total source outage is also made visible: each sync exits non-zero when every request to its source fails. The steps are continue-on-error, so the healthy source still lands and commits. If at least one source committed, the run ends with a warning naming the outage; if every source is unreachable, or a source failed for a reason other than an outage, the run is red.

Usage analytics

Two layers, both cookieless and free-tier:

Traffic and Web Vitals — Cloudflare Web Analytics. Dashboard → Web Analytics → add wallpapers.okeyamy.xyz → automatic setup injects the beacon at the edge, so there is no code to change. This gives page views, top pages, referrers, countries, devices and real-user Core Web Vitals (LCP and friends).

Internal usage — the USAGE Analytics Engine dataset in wrangler.toml. worker.js writes one anonymous data point per event; the dataset is created automatically on the first write after deploy. What is recorded:

Event Subject Number Where
open wallpaper id — lightbox opened
download wallpaper id — counted at /dl/ itself, so hotlinks count too
filter ratio:tall, hue:red, sort:rand, search — filter/sort/search used
preview wallpaper id load time in ms real lightbox speed

No IPs, no user ids, no cross-site identifiers, and search records only that a search happened, never the query text.

Reading it

The dashboard shows the raw positional columns (blob1, blob2, double1), which is hard to read. scripts/usage_report.py queries the SQL API and prints a plain-English summary: what people did, most-opened and most-downloaded wallpapers with their titles, filter usage, preview p50/p90/p95 speed and a per-day table.

Add a token to .env.local (dash → My Profile → API Tokens → Create Custom Token → Account | Account Analytics | Read), then:

python scripts/usage_report.py --days 7

CF_ACCOUNT_ID falls back to the R2_ACCOUNT_ID already in .env.local.

Query it with the Analytics Engine SQL API (an API token with Account Analytics Read), e.g. the most-opened wallpapers this week:

curl "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/analytics_engine/sql" \
  --header "Authorization: Bearer $CF_API_TOKEN" \
  --data "SELECT blob2 AS id, SUM(_sample_interval) AS opens
          FROM wallpapers_usage
          WHERE blob1 = 'open' AND timestamp >= NOW() - INTERVAL '7' DAY
          GROUP BY id ORDER BY opens DESC LIMIT 20"

Other useful queries: swap the WHERE clause to blob1 = 'download' for popularity by downloads, or use SELECT blob2 AS id, SUM(_sample_interval * double1) / SUM(_sample_interval) AS avg_ms FROM wallpapers_usage WHERE blob1 = 'preview' GROUP BY id ORDER BY avg_ms DESC to find the slowest-loading previews. These events also plug into Grafana if you want charts rather than SQL output.

Licence

Site code: MIT. The wallpapers are not covered — copyright remains with the original artists, and each item links back to its source post. Open an issue to request removal.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages