detain / phlix-plugin-anidb
AniDB metadata provider — anime titles, descriptions, episodes, ratings via UDP API and title dump.
Package info
github.com/detain/phlix-plugin-anidb
Type:phlix-plugin
pkg:composer/detain/phlix-plugin-anidb
Requires
- php: >=8.3
- ext-mbstring: *
- ext-sockets: *
- ext-zlib: *
- detain/phlix-shared: ^0.52.0
- psr/container: ^1.1 || ^2.0
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-04 05:58:43 UTC
README
AniDB metadata provider plugin for Phlix — anime titles, descriptions, episodes, ratings via UDP API and daily title dump.
Overview
This plugin fetches structured anime metadata from AniDB using:
- UDP API (
api.anidb.net:9000) — fetch anime details, descriptions, episodes - Daily title dump (
anime-titles.dat.gz) — fast offline title→AID lookups without hitting the API
Upstream status — UDP live lookup is BANNED (504) pending client registration
AniDB answers this plugin's AUTH datagram with 504 CLIENT BANNED: the
client identity it sends (client=phlix, clientver pinned to this plugin's
manifest version) has never been registered with AniDB, and unregistered
names are refused. Wire-verified 2026-11-13 — see
docs/captures/anidb-udp-wire-2026-11-13.md.
Consequences until a client registration with AniDB lands (an owner/vendor action, not a setting in this plugin): every UDP API capability below — live metadata, descriptions, episode detail, ratings — fails with the ban error and returns no data. The daily title dump is a plain HTTPS download that needs no session, is unaffected, and keeps working, so offline title→AID resolution still succeeds. Install and configure with exactly this expectation; the title dump is currently the whole working surface.
Features
- Title dump search — offline exact/prefix/contains match search across all AniDB anime titles (exact hits resolve in O(1) from a lowercase-title index built once per load; near-misses are ranked by length similarity — not fuzzy matching)
- Full metadata — romaji/english/kanji titles, synonyms, year, type, rating (the
genreskey is always empty — AniDB category tags are not in the fetched response, see Protocol Notes) - Description — fetch long descriptions via separate ANIMEDESC command, paginating multi-part synopses to completion
- Flood protection — minimum 4-second pacing of every UDP packet (commands, AUTH, PING, LOGOUT alike), host-wide when the shared ledger is wired (per AniDB rules)
- Session management — lazy keep-alive PING before the next command once idle ~30 min (no timer), auto-reconnect on 506 SESSION EXPIRED
- Episode info — episode number parsed from the filename by
src/Parser/EpisodeExtractor.phpand returned asepisode_number
Install
The plugin is unsigned by design. Install via the Phlix admin UI:
-
Log in to your Phlix server as an admin user (
users.is_admin = 1). -
Browse to
/admin/plugins. -
Paste this URL into the Install from URL form:
https://raw.githubusercontent.com/detain/phlix-plugin-anidb/master/plugin.json -
The server downloads and validates the manifest, runs
composer install --no-dev, and stores a row in thepluginstable. -
Configure your AniDB credentials in the plugin settings form:
- AniDB Username: your AniDB username
- AniDB UDP API Key: the API password you set in your AniDB profile (Settings → Account → API), NOT your login password
If either is missing or empty, AUTH is refused before any datagram is sent with
AniDB: the "AniDB Username" and "AniDB UDP API Key" settings are required (missing or empty: …), naming each unusable field by its form label. A server-side500 LOGIN FAILEDsurfaces asAniDB AUTH failed: invalid "AniDB Username" or "AniDB UDP API Key" …. -
Enable the plugin.
First enable without credentials
Enabling before the credentials exist is accepted, not rejected — by design.
Nothing validates the pair at enable time: a missing (or explicitly empty)
username / api_key normalizes silently to unset with no log line, and a
present-but-wrong-type value is collapsed to unset with a one-line notice naming
the key and its type (never the secret). onEnable() is wiring only — it opens
no socket, sends no datagram, touches no disk — so the admin UI shows a clean
enable either way.
The refusal surfaces at use time instead: the first metadata lookup that
needs a live session is answered with
AniDB: the "AniDB Username" and "AniDB UDP API Key" settings are required (missing or empty: …) before any datagram leaves the host, naming each
unusable field by its form label. Fill both settings and the refusal goes away
(the provider reads its settings at construction; if a long-lived worker keeps
refusing after a save, re-enable the plugin so it re-reads).
Meanwhile the title dump does not wait for credentials. The dump is a plain HTTPS download that needs no session, so a credential-free enable still fires the first download and builds the offline title→AID index on the first lookup (see "Title-dump timing and disk expectations"). Under the standing UDP ban in "Upstream status" that index is currently the whole working surface anyway: enabling with no credentials gives you exactly offline title resolution — and, once credentials exist, everything the moment the UDP path opens again.
Testing credentials — the admin Test button
Before (or without) enabling, the plugin-admin Test button lets you check
a typed username/API-key pair. The host probes the entry class for a
testCredentials() method (method_exists, no manifest declaration), finds
one here, and forwards the form's settings map to
AnidbMetadataProvider::testCredentials(). What the probe does:
- Runs a disposable AUTH ladder on the SUBMITTED pair (an empty or absent
form field falls back to the stored value, so leaving the secret blank tests
the stored key). It never re-authenticates the provider's live lookup
session. Every ladder packet reserves its slot in the plugin's shared
AniDB pacing ledger, so the test stays ≥4 s apart from ALL other AniDB
traffic this host sends — even across the fresh provider instance the host
builds per click. Within one provider instance the ladder additionally
keeps its own flood gate, AUTH-refusal cooldown ledger, and a floor of one
press per 4 s — repeated clicks there are answered with a throttled or
AUTH suppressed: … do not retry within cooldownrefusal instead of more datagrams. - Costs 2–3 paced packets: the
ENCRYPThandshake plusAUTH, and on success a closingLOGOUT(the session would otherwise age out after idle). - Reports a structured outcome, never an exception: success reads
AniDB credentials accepted: the AUTH ladder succeeded.; failures echo AniDB's own refusal vocabulary (the missing-field guard quoted above,500bad credentials,503outdated client,504/555bans — ban-class lines append a pointer to "Upstream status" above — and socket/bind failures), all credential-free by construction and redacted again host-side.
Two honest caveats. First, until the client registration described under
"Upstream status" lands, AUTH answers 504 CLIENT BANNED whatever the
credentials are — a failing test today is that standing ban, not proof your
key is wrong. Second, the end-to-end AUTH+LOGOUT round trip needs the live
UDP endpoint and real credentials, so it cannot be verified from CI or a dev
checkout: the unit suite pins the contract (submitted-over-stored pairing,
guard wording shared verbatim with the AUTH-time guard, refusal mapping, the
4 s floor, cooldown consumption, the ladder's shared-ledger reservation —
including a fresh provider instance deferring to the ledger a previous
instance wrote — and teardown) against scripted transports only.
Unexpected (non-refusal) failures are named in the server error log under the
line prefix AnidbMetadataProvider::testCredentials.
Requirements
- PHP >= 8.3 with
ext-sockets(AniDB UDP transport),ext-openssl(AES-128-ECB encryption of theENCRYPTpacket — see "Protocol & credential posture"),ext-zlib(title-dump gzip handling) andext-mbstring(title normalization) — all four are declared incomposer.json, so the host'scomposer installrefuses to install onto a runtime that lacks them. - Workerman is provided by the Phlix server runtime and is deliberately
not a composer dependency of this plugin. The deferred title-dump
download uses
Workerman\Http\Client/Workerman\Timerwhen present (class_exists-guarded); outside a Workerman runtime (plain CLI, unit tests) the download is skipped rather than blocking, and the UDP path serves. See "AniDB Protocol Notes". - Phlix server (capability) - enrichment needs a server built after the
v1.2.3 tag. On 1.2.0-1.2.3 installs the plugin still installs, configures
and enables (it appears in the admin), but no host code there consults or
consumes AniDB metadata: the plugin-source consultation and background
enricher that drive consumption landed on
phlix-servermaster after v1.2.3 was tagged, and every host build through v1.2.3 self-reports version1.2.3(Version::STRINGis frozen there), soplugin.jsoncannot express aphlix_min_server_versionthat separates the two eras. The declared floor (1.2.0) therefore covers install/enable mechanics only. On 1.2.0-1.2.3 nothing errors and nothing is logged - items simply never receive AniDB metadata.
Non-blocking behaviour (resident worker)
The UDP path is async-native by default. CooperativeWaiter (the default
WaiterInterface) suspends the current Fiber and resumes it from the host event
loop (Revolt\EventLoop, else a one-shot Workerman\Timer), and
SocketUdpClient waits for AniDB replies with non-blocking socket_select()
polls that yield between polls. A silent AniDB therefore never parks the worker
for the 10 s budget or the flood-protection reservation when the lookup runs inside
a Fiber (Workerman 5 request handlers do): the reply is polled in yielding slices,
and pacing waits are taken through the waiter seam in chunks of at most one 4 s
flood interval, so neither a silent server nor a throttled sender parks the worker
beyond one chunk. Outside a Fiber (plain CLI, unit
tests) there is no loop to yield to, so the wait is a bounded blocking
select/usleep. Hosts can inject their own WaiterInterface /
CooperativeWaiterInterface; ProductionWaiter is the explicit blocking
choice for dedicated UDP workers.
Configuration
Configure these in the Phlix admin Plugins → Configure dialog.
| Setting | Type | Required | Default | Description |
|---|---|---|---|---|
username |
string | Yes | — | Your AniDB account username. Register free. |
api_key |
string (secret) | Yes | — | The UDP API Key (API password) set in your AniDB profile under Settings → Account → API — separate from your login password. See the AniDB API docs. |
use_title_dump |
boolean | No | true |
Download the daily title dump for fast offline title→AID resolution (reduces rate-limited API calls). Only the title lookup is offline: an anime's details still come over the authenticated UDP API session, so the username + api_key settings above remain required for metadata. |
title_dump_url |
string | No | https://anidb.net/api/anime-titles.dat.gz |
URL to anime-titles.dat.gz. Change only for a mirror. Must be HTTPS. AniDB's Cloudflare front answers plain HTTP with 403, so any other plain-HTTP URL is refused (no download, a REFUSING log line) unless the server environment sets PHLIX_ANIDB_ALLOW_HTTP_DUMP_MIRROR=1. See "Protocol & credential posture". A stored http://…anidb.net/… value from before 0.4.1 is migrated to https automatically. |
cache_dir |
string | No | — | Absolute path of a writable directory for the title-dump index. It must live outside the read-only plugin tree (systemd sandbox). It must not be world-writable, because the index is served from it. A relative path, a non-string value, or an existing world-writable directory is refused at construction with a loud error. Unset falls back to the PHLIX_ANIDB_CACHE_DIR environment variable (same rule), then the system temp dir. |
The title-dump index is written to a writable cache directory outside the plugin tree, resolved in this order: constructor argument → cache_dir setting → the PHLIX_ANIDB_CACHE_DIR environment variable → sys_get_temp_dir()/phlix-plugin-anidb.
The AniDB UDP API authenticates with your username + a separate API Key you set in your profile (not your website login password). Set the API Key under your AniDB profile → Settings → Account → API.
Environment variables
These are process-environment variables for the Phlix server (set them in
/etc/phlix/env, the systemd unit, or wherever the server process gets its
environment) — not settings-form fields.
| Variable | Effect |
|---|---|
PHLIX_ANIDB_CACHE_DIR |
Cache-directory fallback when the cache_dir setting is unset. Same rules as the setting: absolute path, writable, not world-writable. Resolution order: constructor argument → cache_dir setting → this variable → sys_get_temp_dir()/phlix-plugin-anidb. |
PHLIX_ANIDB_ALLOW_HTTP_DUMP_MIRROR |
Opt-in escape hatch for a genuinely HTTPS-less dump mirror. Only the exact value 1 counts as opt-in (0, true, yes, padded values do not). With it set, a cleartext title_dump_url fetches anyway and logs a cleartext warning on every attempt; the default posture is to refuse it (see "Protocol & credential posture"). |
PHLIX_ANIDB_CA_BUNDLE |
Path to a CA bundle pinning the trust root for the title-dump HTTPS download. AniDB serves normal public-CA-issued certificates, so most operators never need this — it exists for egress paths that deliberately terminate TLS in the middle and where the operator wants to pin that chain. Strict certificate verification is ALWAYS on regardless (peer name checked, self-signed never accepted); this knob only selects the trust store. A set-but-unreadable (or non-file) value fails LOUD — the attempt is refused with PHLIX_ANIDB_CA_BUNDLE is set but does not name a readable file: <path> rather than silently falling back, because a misconfigured pin is a mistake, not a preference. |
PHLIX_ANIDB_DEBUG |
Any value other than empty or 0 makes the title-dump indexer's operator log lines carry full absolute paths where they would otherwise show basenames only (log paths are basename-only by default so shared logs do not disclose the install layout). The one line that must be actionable regardless — the STALLED blocker path — is always printed in full. |
How It Works
The plugin is consumed through the host SourceRegistry: the server's
PluginLoader::enable() registers this provider — it implements the typed
Phlix\Shared\Metadata\MetadataSourceInterface contract — into the registry,
and enrichment flows SourceRegistry → PluginSourceConsultation /
PluginMetadataEnricher. The interface triad internally bridges through a
thin AnidbMetadataProviderAdapter (the adapter's surface is
search/getDetails/getImages/getProviders/getSourceName; the
file-path-based lookup() lives on the wrapped provider in
src/AnidbMetadataProvider.php, not on the adapter):
- search(title) — resolve an anime title to an AID using the title dump or API fallback
- getDetails(aid) — fetch full anime metadata by AID
- lookup(filePath) — extract anime name from a file path and return metadata
Internal flow (when lookup() or getDetails() is called):
- Fetch details — send
ANIME aid=...for full anime data - Fetch description — send
ANIMEDESC aid=...&part=0; when the reply's parts column promises more, every remaining part is fetched in order (one paced UDP packet each) and concatenated — the full synopsis, never a silently truncated first part - Map response — translate AniDB field layout to the host metadata pipeline's expected return shape
Registration (onEnable()) does wiring only — the socket, title-dump download and
index load are deferred to the first real lookup so plugin boot never blocks the
resident Workerman worker.
Title-dump timing and disk expectations
When the download runs, what it costs, and what lands on disk — the contract an
operator should plan around (all of it is pinned by the constants in
src/TitleDump/TitleDumpIndexer.php and src/TitleDump/TitleDumpManager.php):
- First download fires on the first lookup, never on enable. The enable pass is network-free by design (a blocking fetch in it once stalled every Workerman worker for the full HTTP budget and had to be reverted). The first lookup reads a cached index if one exists and otherwise arms the download as a real off-loop async fetch on the pumping event loop (since S-anidb-11 there is no busy-wait at all): the worker keeps serving while the response or its deadline settles inside the loop.
- 24-hour cadence.
title_index.jsoncounts as stale when its file mtime is older than 24 hours. Inside a resident process the freshness check rides the lookup path but is itself throttled to at most once per 60-second window (one stat between windows), and when it finds the index stale — or finds the file on disk newer than what the process memoized (a sibling rewrote it) — it (re-)starts the download and reloads the memo when the file moved. So: roughly one download per day per shared cache directory, not per lookup, not per worker. - A 120-second in-flight marker is the concurrency limit and the retry floor.
Each attempt claims
title_index.download.lock; the claim expires after 120 seconds (deliberately larger than the 60-second HTTP timeout, so a slow but legitimate fetch can never be double-started). Two consequences: a worker killed mid-download cannot wedge the index for more than two minutes, and a failed attempt keeps its marker, so 120 seconds is also the minimum gap between retries — a fast-failing fetch (dead DNS name, instant-5xx mirror) cannot turn into a download storm, because AniDB bans on request floods. A future-dated marker (clock skew, backup restore) is treated as expired and safely reclaimed. - Wire and memory volumes are small with hard caps around them. The real
anime-titles.dat.gzis roughly 1.5 MB on the wire. Per attempt the indexer refuses anything beyond: 16 MiB compressed, 64 MiB decompressed (gzip-bomb guard — reaching the cap aborts fail-closed instead of parsing), 4096 bytes per dump line, 1,000,000 records (a legitimate dump carries a few hundred thousand title rows). The 16 MiB compressed cap binds progressively: the async fetch refuses mid-stream once the accumulating received chunks pass it — or outright at header time whenContent-Lengthalready declares more — so an oversize response is bounded by peak memory before it finishes buffering, with the final whole-body check kept as the belt for any other transport shape. A cap breach refuses the whole dump loudly and writes nothing, because a silently truncated index would poison every lookup under the dropped AIDs. Non-2xx responses (404/503/3xx) are refused by HTTP status before their body is read at all, so an upstream outage is logged as the status failure it is and never misattributed to dump corruption. The raw.gzis never persisted — it is decompressed and parsed in memory. - What persists on disk is only the index.
title_index.json(entries shaped{aid, titles:[{title, type, lang}…]}) is written pretty-printed for humans — so it is a multi-megabyte plain file even though the wire dump is ~1.5 MB — staged to atitle_index.json.<hex16>.tmpsibling and renamed into place (a symlink planted at the index name is refused, never followed). On the read side an index file over 128 MiB is treated as corrupt and the process falls back to an empty index rather than slurping it.
Media types, provider family, and pacing
- This plugin registers for
seriesandmovie—supportedMediaTypes()returns exactly['series', 'movie']. There is noanimetype in the host schema (and noanimemedia-type claim here): anime is treated as ordinary series/movie and matched by title through the existing enrichment path. The manifest carries nodeps/conflictskeys — the relationship between providers is entirely at the type level, not declared in the manifest. - Alongside myanimelist and anilist, precedence is host-side.
phlix-plugin-myanimelistandphlix-plugin-anilistregister for the sameseries/moviepath, so for an anime title all consulted providers compete on that one lane and the host's SourceRegistry consultation order governs whose data lands first. Aprovider_priorityentry naminganimechanges nothing on this path: it is never consulted by anything (noanimemedia type exists in the schema, library creation refuses it, and although the admin editor may still render an inert Anime row from the shipped defaults, it has no effect on consultation). This plugin ships no precedence knob and does not read the other plugins' data. - The 4-second floor is shared through the cache directory — same directory
only. Every AniDB-family client on Earth is subject to the same per-IP+port
rate limits, and AniDB's
555reply exists precisely to punish burst traffic. Inside Phlix the floor is enforced by a file pacing ledger (anidb-udp-ledger) plus a single-socket-owner election (anidb-udp-owner.lock) in the validated cache directory: every server process pointed at the samecache_dirshares one 4-second floor and one source port (both control files are tightened to0600on every open, and the directory must not be world-writable, or a local peer could forge pacing slots). What the ledger cannot see: another Phlix install with a different cache directory, or any non-Phlix AniDB client on the same egress IP. If such a client exists, leave the AniDB rate budget room for it — running two uncoordinated AniDB clients from one IP is exactly the multi-connection pattern that earns bans.
AniDB Protocol Notes
- Protocol: UDP (not HTTP) to
api.anidb.net:9000 - Client registration: the shipped
client=phlixidentity is not registered with AniDB, soAUTHis refused with504 CLIENT BANNED— live UDP lookup does not work until registration lands (see "Upstream status") - Flood protection: minimum 4 seconds between EVERY packet — commands,
AUTH,PINGandLOGOUTalike; AniDB's short-term "first 5 packets" allowance is deliberately unused (no burst counter). With the shared pacing ledger wired the slot is reserved host-wide, not per process - Session: valid 35 minutes; keep-alive via a lazy
PINGbefore the next command once idle ~30 min (never on a timer; the server answers a barePINGwith300 PONG) - Flood ban: reusing the same local UDP port is critical to avoid IP-level bans
- Field coverage: the ANIME amask in use (
00f0f0f0000000) returns titles, episode/date and rating fields only — AniDB's category/genre tags are not part of that response, sogenresis structurally always empty (deriving real genres would additionally require vote/weight filtering over the tag cloud)
Protocol & credential posture
The AniDB UDP API has no TLS and no TCP alternative, but it does offer packet
encryption: the client opens every session with ENCRYPT user=<name>&type=1
(the server answers 209 <salt> ENCRYPTION ENABLED), derives an AES-128 key as
md5(api_key + salt), and sends the AUTH datagram and every later command
encrypted. This handshake was verified against the live server (see
docs/captures/anidb-udp-wire-2026-11-13.md). The client requests only
type=1 (AES-128-ECB); type=2 (Blowfish) is deliberately not implemented, so a
server that would accept only type=2 lands in exactly the refusal case below. If
the server ever refuses ENCRYPT, the client logs that and falls back to the
cleartext pass= AUTH, in which case any party on the network path between the
Phlix server and
api.anidb.net:9000 could read those bytes. Mitigations, in order of
importance:
- Use a dedicated AniDB account for Phlix, never your personal one.
- Set an API password that is unique to AniDB and not reused anywhere (it is already separate from the site login password — see Settings above).
- Run Phlix on trusted network infrastructure; if in doubt, confirm with your
host that the egress path to
api.anidb.netis not shared with untrusted tenants.
Reply-origin check is an address allowlist, not authentication. A UDP reply
is accepted only if it comes from port 9000 on one of the resolved IPs of
api.anidb.net (DNS is resolved again every hour). That drops stray and
misrouted datagrams, but UDP does not authenticate source addresses, and AniDB
does not sign its replies. Anyone on the network path, or anyone who can spoof
AniDB's source IP and port and get the timing right, can still get a forged
reply accepted. That reply could be fake metadata or a fake AUTH/session
answer. The protocol cannot close this gap. The mitigation is the same trusted
network path described above.
title_dump_url must be HTTPS (default-deny cleartext). The title dump
feeds every worker's offline title→AID index, and a plain-HTTP download has no
certificate to verify, so anyone on the network path could serve a forged dump.
A non-HTTPS title_dump_url is therefore refused: each download attempt
logs TitleDumpIndexer: REFUSING download — title_dump_url uses cleartext HTTP (http://<host>) and contacts nothing, and the previously cached index (if any)
keeps serving. If your mirror genuinely has no HTTPS, set the environment
variable PHLIX_ANIDB_ALLOW_HTTP_DUMP_MIRROR=1 (exactly 1) for the Phlix
server process; the fetch then proceeds and logs a cleartext warning on
every attempt. Redirects are never followed, so an https URL cannot be walked
down to http by a 301 either way.
title_dump_url fetch reachability (deferred guard). The server fetches
whatever URL the title_dump_url setting names. The setting lives in the
plugin settings form (advanced tier), so only an administrator can change it.
Members cannot reach it. The fetched body is never shown to anyone. A
non-2xx response is refused by HTTP status before its body is read at all;
a 2xx transfer is refused mid-stream once the accumulating body passes the
16 MiB compressed cap (or at header time when Content-Length declares
more) — the bound is on peak memory while receiving, not merely on
eventual acceptance — and whatever does arrive is thrown away unless it
decompresses within the 64 MiB ceiling and parses as a valid title dump.
Bytes still in flight after a refusal are left to the HTTP library's own
connection lifecycle (the callback API offers no mid-stream socket
teardown); the response is never read, decompressed, parsed or indexed by
this plugin. Logs carry only refusal reasons, byte counts, the scrubbed URL
and the transport error class/message — never body content. There is no
host allowlist and no private/loopback-range deny on this URL today, so an
administrator can point the fetch at an internal address and the server will
send that request; only the transport outcome is logged. This is accepted
because only administrators can set the URL.
If title_dump_url ever becomes settable by members, a host
allowlist or a private-range deny must ship in the same change.
See the AniDB UDP API docs for full details.
Data Returned
[
'title' => 'Seikai no Monshou', // Primary romanized title
'original_name' => 'Crest of the Stars', // English official title (or kanji)
'overview' => 'A space opera...', // Description (fetched separately)
'year' => 1999, // First release year
'genres' => [], // Always empty — categories not in the fetched amask
'rating' => 8.53, // AniDB rating (0-10)
'vote_count' => 3225, // Number of votes
'poster_url' => 'https://cdn-eu.anidb.net/images/main/1.jpg', // null if no picname
'fanart_url' => null, // Not provided by AniDB
'episodes' => 13, // Episode count (null if unknown)
'type' => 'tv', // Normalized type (tv, movie, ova, etc.)
'anidb_id' => 1, // AniDB AID
'titles' => ['Seikai no Monshou', 'Crest of the Stars', '星界の紋章'],
'status' => 'Finished', // Finished / Currently Airing / Upcoming
'runtime_ticks' => null, // Not provided by AniDB
'studio' => null, // No studio field; AniDB's studio data lives in categories (not fetched)
'studios' => [], // Same, as a list
'source' => null, // Source material, when known
'is_movie' => false, // Derived from type / filename pattern
'synonyms' => ['Crest of the Stars'], // True synonyms from the ANIME response (field 11); short_names (field 10) also feed 'titles'
'description_fetch_failed' => false, // true when the synopsis (ANIMEDESC) fetch failed — distinguishes "no synopsis exists" from "synopsis fetch failed"
'episode_number' => 1, // Parsed from the filename; key is ABSENT (not null) when the filename yields none
]
Troubleshooting — the refusal vocabulary
Every refusal this plugin emits, what it means, and what (if anything) to do.
The cache-directory REFUSING family and STALLED log once per process —
silence after the first line is not recovery; the condition stands until fixed.
| Log / reply line | Meaning | What to do |
|---|---|---|
AniDB: the "AniDB Username" and "AniDB UDP API Key" settings are required (missing or empty: …) |
No usable credentials — refused before any datagram is sent. | Fill both settings (see "First enable without credentials"). The title dump keeps working meanwhile. |
AniDB AUTH failed: this client version is banned (your account is not) (the standing 504 CLIENT BANNED) |
Upstream policy: the shipped client=phlix identity is not registered with AniDB yet. Your account and key are irrelevant to this answer. |
Nothing operator-side — see "Upstream status". Title-dump matching continues. |
AniDB AUTH failed: temporarily banned (555 BANNED) |
AniDB burst-punishment aimed at your IP+port: something recently sent AniDB too much traffic too fast. | The plugin already silences itself — further sends are suppressed for a cooldown that doubles 60 → 120 → 240 → 480 → 900 s (held), so it never spends more than one ladder per quarter-hour. Check that no other AniDB client shares the egress IP, and don't churn restarts to "make it retry" sooner. |
AUTH suppressed: … do not retry within cooldown |
A retry landed inside the cooldown above — informational, no datagram was sent. | Wait it out; the escalation already protects the ban. |
AniDB AUTH failed: invalid "AniDB Username" or "AniDB UDP API Key" (500 LOGIN FAILED) |
The pair itself was refused. | Recheck the username and that api_key is the API password from profile → Settings → Account → API, not the login password. (Under the standing 504 ban a credential error cannot even be reached — 504 answers first.) |
503 CLIENT VERSION OUTDATED |
AniDB rejects this client version string itself. | Update the plugin; if current, it is an upstream-side version gate. |
TitleDumpIndexer: REFUSING to download the AniDB title dump — the cache directory "…" will not accept the in-flight marker … |
The cache directory cannot hold a marker file: ownership/permissions, out of space, or the systemd sandbox does not list it under ReadWritePaths. |
Fix the directory (the line names the levers, including PHLIX_ANIDB_CACHE_DIR). Until it works, the dump never refreshes; any cached index keeps serving. |
TitleDumpIndexer: REFUSING download — title_dump_url uses cleartext HTTP (…) |
Default-deny on an unencrypted dump fetch (a forged dump poisons every worker's index). | Set the URL back to HTTPS, or opt into cleartext deliberately with PHLIX_ANIDB_ALLOW_HTTP_DUMP_MIRROR=1 (exactly 1). |
REFUSING lines naming the response size, not valid gzip, decompressed-cap reached, zero valid entries, record/line/aid ceilings |
The fetched body was not a sane title dump — broken mirror, error page served as the payload, or a hostile one. Every ceiling refuses the whole body and writes nothing. | Point title_dump_url at a working mirror. The previously cached index (if any) keeps serving. |
STALLED … (the marker path is not a regular file) |
title_index.download.lock exists but is a directory or symlink — nothing in Phlix creates that shape; it is an operator artifact (a restore, a hand-made directory, a planted symlink). The dump will never update again while the blocker stands. |
The line prints the blocker's full path. Delete exactly that path (recursively if it is a directory); nothing else in the cache dir needs touching. |
AnidbMetadataProvider: UDP open() failed (…); provider degrades to title-dump matching for this pass |
Could not open/bind the UDP socket this pass (port busy, egress blocked). | Check firewall/egress for UDP :9000 and that no other process squats the port. Offline title matching continues; the next lookup retries the open. |
AniDB: server refused ENCRYPT (…) |
The server would not enable packet encryption; this session falls back to cleartext pass= AUTH. |
See "Protocol & credential posture" — a dedicated account and unique API password are the mitigations. |
PHLIX_ANIDB_CA_BUNDLE is set but does not name a readable file: <path> |
The pinned trust store is misconfigured; the attempt is refused fail-loud rather than silently skipped. | Fix the path (or unset the variable to use the system trust root). |
Uninstall and the files it leaves behind
Disabling or uninstalling deletes no files — by design, so a reinstall
finds its cache intact. onDisable() cancels any deferred download (deleting
the timer and releasing un-started claims), closes the UDP session and any
credential-test ladder session, and drops its references; there is no uninstall
hook and no cleanup anywhere else.
Everything the plugin ever wrote lives inside the resolved cache directory
(default sys_get_temp_dir()/phlix-plugin-anidb when neither the setting nor
PHLIX_ANIDB_CACHE_DIR names one):
anidb-udp-owner.lock— the single-socket-owner election lockanidb-udp-ledger— the shared 4-second pacing ledgertitle_index.download.lock— the in-flight download marker / retry floortitle_index.json— the offline title→AID indextitle_index.json.<hex16>.tmp— a staged index write, present only if a write crashed mid-rename
The three control files (anidb-udp-owner.lock, anidb-udp-ledger,
title_index.download.lock) are 0600; the index — and any staged temp — is
0644: the content is public dump data, served world-readable by design,
while never being world-mutable. All are inert once the plugin is gone — no
running code reads them again. Deleting the whole directory is safe (and is the
right move when clearing a leftover after uninstall); a fresh install
re-seeds everything on its first lookup, re-downloading the dump as needed. On
hosts with a tmp-cleaner, the default location may be swept periodically with no
consequence beyond one re-download.
Fork as a Starter
This plugin is based on phlix-plugin-example. To create your own metadata provider:
- Fork or copy this repository.
- Edit
plugin.json— pick a newname(must start withphlix-plugin-), setversionto0.1.0for your fork, changeentryto your FQCN. - Edit
composer.json— rename the package, update PSR-4 autoload prefix. - Replace
src/AnidbMetadataProvider.phpwith your own implementation. - Run tests:
composer install && vendor/bin/phpunit.
Testing
composer install vendor/bin/phpunit vendor/bin/phpunit --testdox # verbose output vendor/bin/phpstan analyse --no-progress # static analysis, level 9 over ALL of src/ — zero ignoreErrors, zero excludes (phpstan.neon) php scripts/security-audit-check.php # security audit over the whole lock (require + require-dev)
License
MIT — see LICENSE.