Skip to content

v2.6.1 — Sweep Fixes, Stream Resolver Rebuild & AniList Enrichment

Latest

Choose a tag to compare

@Shineii86 Shineii86 released this 26 Oct 02:29
· 1 commit to main since this release

AniKotoAPI v2.6.1

Full release covering 2.6.0 + 2.6.1 — both shipped 2026-10-24 (2.6.0 never got its own tag). Three sessions in one: the 2.6.0 architecture push (modular middleware/routes, AniList enrichment, cache controls), the 2.6.1 stream-resolver rebuild, and the follow-up full diagnostic sweep that closed every P0–P3 finding.


Added

  • AniList Enrichment — GET /api/anilist/:id (also ?mal=21) returns synopsis, genres, scores, studios, characters, relations, recommendations and next-airing data straight from AniList's public GraphQL API — no scraping, immune to origin-site Cloudflare challenges. Unknown media returns 404, an AniList outage returns 502.
  • Seasonal Chart — GET /api/anilist/season?season=WINTER&year=2026&page=1&perPage=25, defaults to the current season/year, 30 min cache per season/page.
  • AniList Client — src/helper/anilist.helper.js (cached GraphQL client + MAL→AniList ID map, 60 min) shared by /anilist, info.externalIds and /stream/embeds.
  • Modular Stack — middleware extracted to src/middleware/ (request ID, CORS, security headers, rate limit, timeout, validation), routes split into src/routes/* domain modules, spec builder moved to src/configs/openapi.config.js (49 paths / 13 tags); server.js is now a pure composition root.
  • Cache Controls — ?refresh=1 bypasses the LRU for the whole request chain (AsyncLocalStorage scope) with X-Cache: HIT/MISS/BYPASS headers, plus an in-flight request registry so a cold key can no longer fan out into 5-mirror stampedes.
  • TRUST_PROXY — rate limiting keys on the real client IP behind Render/Vercel/nginx instead of the proxy's address (one noisy client can no longer 429 the whole API).
  • Response Sanitizer — new src/middleware/sanitizeJson.middleware.js: decodes HTML entities (&, ', non-terminated &NBSP 1999), collapses whitespace runs and coerces stringified identity keys to numbers on every JSON response.
  • Rate-Limit Skip — /api/health and /api/openapi are exempt from the limiter so monitoring and spec readers are never throttled out of the window.
  • Tests — 16 new sweep-regression cases (real seasons/watch-order, ranking windows, error mapping, strict validation, payload hygiene); suite now 64 tests, and the runner prints its count after the dynamic injections so the number always matches the list.

Fixed

  • Seasons & Watch Order (P0) — both endpoints served the generic trending sidebar for every anime; they now parse the real upstream AJAX fragments GET {base}api/seasons/{animeId} and GET {base}api/watch-order/{animeId} (XHR header + Referer). Naruto → 4 real seasons (Classic Series, Shippuden Series, …), One Piece → honest totalSeasons: 0, watch-order → 56 One Piece / 25 Naruto related entries, deduped with the anime itself excluded. Slug and numeric forms work — /api/seasons/1642 used to answer 500.
  • Top Rankings (P0) — the selector merged all three homepage tabs (27 items, ranks 1–27, byte-identical output for every ?sort=). Now scoped per window: 9 unique slugs ranked 1–9 each, day ≠ week ≠ month, and an unknown sort returns 400 instead of silently falling back.
  • Fast-Fail Error Mapping (P1) — client faults no longer replay across every mirror with backoff: structured upstream 4xx/"Bad request" answers are terminal on the first try, so a bad slug returns 404 in ~0.5–1 s instead of 500 after 13–16 s; the status propagates through all 42 route catch blocks (plus /stream, which used to wrap everything as a 502).
  • JSON 404s — unknown /api/* paths return { success: false, message: "Endpoint not found" } instead of the HTML error page; 429s carry the creator envelope again (limiter now runs after the attribution middleware); /api/mirrors/reset gained the standard results key.
  • Stream Resolver (upstream break) — the legacy /ajax/sources host (megaplay-1.buzz) died in DNS, killing /stream/resolve and /stream/qualities. Resolution now calls stream/getSourcesNew → stream/getSources on the embed host and decrypts the AES-256-CBC enc payload (key/IV from the player) to the master.m3u8; the legacy call stays as fallback, kind: "captions" tracks count as subtitles, skipData normalised to the site's [start, end] shape.
  • Stream Qualities — the playlist fetch sent no player-origin Referer and the CDN answered 403, so totalQualities was always 0; it now sends streamRefererHeaders() and returns the real variant list.
  • Info Artifacts — rating reads #w-rating[data-score] (the old text extraction doubled it: "8.73 8.73 /10"), premiered strips upstream's &NBSP, altNames is split + deduped, episodes is null instead of the literal "?".
  • AniList Misses — /api/anilist/999999999 → 404 (was 502).
  • Validation — ?page= / slug / letter guards rejected before any upstream call; embeds lang, ep, mal, anilist now 400 on junk instead of being silently clamped or probed; schedule rejects impossible calendar dates (2026-13-45 → 400).

Changed

  • Strict Qualities — /api/stream/qualities answers 415 when the URL isn't an HLS playlist and 502 when the fetch fails, instead of returning qualities: [] with 200.
  • Proxy Upgrade — playlists rewrite every media reference (bare lines and URI="…" on #EXT-X-KEY/#EXT-X-MAP), one bounded retry on network/429/5xx, segments are streamed with Range forwarded, HTML bodies are rejected instead of served as media, Content-Type derives per extension; live allowlist now covers MegaPlay's current hosts (shiora.top, ivorysummit.world, nexabloom.top, eclipseharbor.space).
  • Schedule Defaults — ?date= is optional (defaults to today) and must be a real YYYY-MM-DD date.
  • OpenAPI — 20 parameters flagged required: true to match the controllers that already 400 on them; refreshed descriptions for the seasons/watch-order sources + relation limitation, ranking windows, qualities 415, embeds one-of and the numeric id types.
  • Docs — docs/endpoints.md, docs/testing.md, docs/architecture.md, docs/index.md and README synced to the new behaviour and the 64-test suite; docs/diagnostic-sweep.md gained a status header pointing at this release.

Example

GET /api/seasons/naruto-eybxz        → 4 seasons (Classic, Shippuden, …)
GET /api/seasons/1642                → { totalSeasons: 0 }   # honest empty
GET /api/watch-order/1642            → 56 related entries, relation: "related"
GET /api/top-rankings?sort=month     → 9 unique slugs, ranks 1–9
GET /api/schedule                    → today's airings (no date needed)
GET /api/schedule?date=2026-13-45    → 400 Invalid date
GET /api/stream/embeds?mal=21        → ids { malId: 21, anilistId: 21 }
GET /api/info?id=one-piece-odmau     → rating "8.73", episodes null, clean titles
GET /api/definitely-not-a-route      → JSON 404

Verified

  • Integration suite: 64 passed / 0 failed / 0 skipped (avg 401 ms)
  • Full diagnostic sweep re-run: 97/97 requests, 0 × 5xx, 0 × 429 — statuses { 200: 50, 400: 33, 403: 3, 404: 11 }
  • node --check clean over all 94 JS files
  • /api/health → 2.6.1, /api/openapi → 2.6.1 / 49 paths, /api/stats → 42 endpoints
  • Bad-slug latency: /episodes/<bad> 0.5–1 s (was 13–16 s), /watch?slug=<bad> 0.47 s, 429 + unknown-path replies verified JSON
  • No secrets tracked in git

Notes for API consumers

  • Numeric identity fields (animeId, malId, anilistId) are now numbers; info.episodes is a number or null
  • Titles/descriptions are entity-decoded and whitespace-normalised
  • watch-order entries all report relation: "related" until upstream fixes its placeholder labels
  • Invalid sort / lang / date and unknown /api/* paths now answer 400 / 404 instead of silently succeeding

Full changelog: CHANGELOG.md
End-to-end endpoint reference: docs/endpoints.md
Diagnostic sweep (cross-repo): docs/diagnostic-sweep.md