perf: lazy-load services and proxy catalogues, faster namespace strip

load_xml strips namespaces without QName; services import on first use and proxy providers fetch their catalogue on first query; the font scan is skipped when no subtitle names a font and is cached per process.

Serve CPU -40% and track requests -28% on 20 MB manifests; CLI startup 2.7 s -> 1.2 s; --list 27-46% faster across six services tested.
This commit is contained in:
imSp4rky
2026-11-04 11:12:11 -07:00
parent b3d586a590
commit 6ca2503a5f
18 changed files with 389 additions and 81 deletions
+4 -2
View File
@@ -1069,8 +1069,10 @@ The returned proxy is HTTPS on **port 443**.
methods:
- `__init__(self, **kwargs)` receives its `proxy_providers` sub-dict splatted as
keyword arguments, so YAML keys map 1:1 to constructor parameters. Do authentication
and catalogue pre-fetching here.
keyword arguments, so YAML keys map 1:1 to constructor parameters. Check the
configuration here, but make no request: every `dl` run builds every configured
proxy provider, even for a run with no proxy. Read the server or location catalogue
through a `functools.cached_property`, so the first query fetches it.
- `__repr__(self)` is a human summary, conventionally `"{n} Countries ({m} Servers)"`.
- `get_proxy(self, query)` returns a Requests-compatible proxy URI, or `None` only
when the query was valid but no proxy exists. Raise on genuine errors or bad queries.