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
+5 -1
View File
@@ -1,6 +1,7 @@
import random
import re
import subprocess
from functools import cached_property
from typing import Optional
from unshackle.core import binaries
@@ -16,7 +17,10 @@ class Hola(Proxy):
raise EnvironmentError("hola-proxy executable not found but is required for the Hola proxy provider.")
self.binary = binaries.HolaProxy
self.countries = self.get_countries()
@cached_property
def countries(self) -> list[dict[str, str]]:
"""Fetched on first use, so a run that wants no proxy makes no request."""
return self.get_countries()
def __repr__(self) -> str:
countries = len(self.countries)