docs: apply simplified technical english across docs and docstrings.

This commit is contained in:
imSp4rky
2026-08-19 16:31:06 -06:00
parent 4177cb2267
commit 66971230c3
135 changed files with 2651 additions and 2570 deletions
+20 -20
View File
@@ -28,11 +28,11 @@ DEFAULT_ORDER: tuple[str, ...] = ("imdb", "omdb", "simkl", "tmdb", "tvdb", "anil
def provider_order(kind: Optional[str] = None, anime: bool = False) -> list[type[MetadataProvider]]:
"""Provider classes in the order configured by `metadata_providers`.
"""Metadata provider classes in the order configured by `metadata_providers`.
`metadata_providers` is either a flat list applying to both kinds, or a mapping of
kind ("tv"/"movie") to its own list. A kind the mapping omits uses `DEFAULT_ORDER`.
An `anime` title puts anilist first; the rest of the order stays behind it to
An `anime` title puts AniList first. The rest of the order stays behind it to
fall back on.
"""
from unshackle.core.config import config
@@ -50,12 +50,12 @@ def provider_order(kind: Optional[str] = None, anime: bool = False) -> list[type
def get_available_providers() -> list[MetadataProvider]:
"""Return instantiated providers that have valid credentials."""
"""Return instantiated metadata providers that have valid credentials."""
return [cls() for cls in provider_order() if cls().is_available()]
def get_provider(name: str) -> Optional[MetadataProvider]:
"""Get a specific provider by name."""
"""Get one specific metadata provider by name."""
cls = REGISTRY.get(name)
if not cls:
return None
@@ -73,7 +73,7 @@ def search_metadata(
cache_account_hash: Optional[str] = None,
anime: bool = False,
) -> Optional[MetadataResult]:
"""Search all available providers for metadata. Returns best match."""
"""Find metadata in every available metadata provider. Returns the best result."""
from unshackle.core.config import config
# the one gate for `disable_metadata`: every automatic lookup reaches a provider through
@@ -295,12 +295,12 @@ def resolve_by_ids(
cache_account_hash: Optional[str] = None,
anime: bool = False,
) -> Optional[MetadataResult]:
"""Resolve metadata from user-supplied external IDs, falling back to search only without them.
"""Get metadata from user-supplied external IDs, and find the title by name only without them.
A supplied ID is authoritative. It is looked up directly through the providers that
consume its namespace, in `metadata_providers` order for `kind`, and it always survives
into `external_ids` whatever a provider answers. A fuzzy title search only runs when no
ID was supplied at all.
A supplied ID is authoritative. unshackle looks it up directly through the metadata
providers that consume its namespace, in `metadata_providers` order for `kind`, and it
always survives into `external_ids` whatever a metadata provider answers. Without any
supplied ID, unshackle finds the title by a fuzzy name comparison.
"""
supplied: dict[str, Union[int, str]] = {}
if tmdb_id is not None:
@@ -366,17 +366,17 @@ ENRICHMENT_AUTHORITY: tuple[str, ...] = ("tmdb", "simkl", "tvdb")
def enrichment_providers(kind: Optional[str] = None) -> list[str]:
"""Names of configured providers that can resolve an IMDB ID, most trusted first."""
"""Names of the configured metadata providers that can find a title by IMDB ID, most trusted first."""
configured = {cls.NAME for cls in provider_order(kind) if hasattr(cls, "find_by_imdb_id")}
return [name for name in ENRICHMENT_AUTHORITY if name in configured]
def enrich_ids(result: MetadataResult) -> None:
"""Enrich a MetadataResult by cross-referencing IMDB ID with available providers.
"""Enrich a MetadataResult by cross-referencing IMDB ID with the available metadata providers.
Queries all available providers, cross-validates tmdb_id as anchor.
If a provider returns a different tmdb_id than the authoritative source,
ALL of that provider's data is dropped (likely resolved to wrong title).
Queries all available metadata providers, cross-validates tmdb_id as anchor.
If a metadata provider returns a different tmdb_id than the authoritative source,
unshackle drops ALL of that metadata provider's data (it likely found the wrong title).
"""
ids = result.external_ids
if not ids.imdb_id:
@@ -417,11 +417,11 @@ def validate_enrichments(
enrichments: list[tuple[str, ExternalIds]],
authority: dict[str, int],
) -> list[tuple[str, ExternalIds]]:
"""Drop providers whose tmdb_id conflicts with the authoritative value.
"""Drop the metadata providers whose tmdb_id conflicts with the authoritative value.
If providers disagree on tmdb_id, the more authoritative source wins
and ALL data from disagreeing providers is discarded (different tmdb_id
means the provider likely resolved to a different title entirely).
If metadata providers disagree on tmdb_id, the more authoritative source wins.
unshackle discards ALL data from a metadata provider that disagrees, because a
different tmdb_id means that metadata provider likely found a different title.
"""
from collections import Counter
@@ -479,7 +479,7 @@ def external_ids_to_dict(ext: ExternalIds) -> dict:
def cached_to_result(cached: dict, provider_name: str, kind: str) -> Optional[MetadataResult]:
"""Convert a cached provider dict back to a MetadataResult."""
"""Convert a cached metadata provider dict back to a MetadataResult."""
if provider_name == "tmdb":
detail = cached.get("detail", {})
ext_raw = cached.get("external_ids", {})
+4 -4
View File
@@ -31,7 +31,7 @@ class ExternalIds:
@dataclass
class MetadataResult:
"""Unified metadata result from any provider."""
"""Unified metadata result from any metadata provider."""
title: Optional[str] = None
year: Optional[int] = None
@@ -71,11 +71,11 @@ class MetadataProvider(metaclass=ABCMeta):
@abstractmethod
def is_available(self) -> bool:
"""Return True if this provider has the credentials/keys it needs."""
"""Return True if this metadata provider has the credentials/keys it needs."""
@abstractmethod
def search(self, title: str, year: Optional[int], kind: str) -> Optional[MetadataResult]:
"""Search for a title and return metadata, or None on failure/no match."""
"""Find a title and return its metadata, or None on failure or when nothing matches."""
@abstractmethod
def get_by_id(self, provider_id: Union[int, str], kind: str) -> Optional[MetadataResult]:
@@ -95,6 +95,6 @@ def strip_year(s: str) -> str:
def fuzzy_match(a: str, b: str, threshold: float = 0.8) -> bool:
"""Return True if ``a`` and ``b`` are a close match."""
"""Return True if ``a`` and ``b`` match closely."""
ratio = SequenceMatcher(None, clean(a), clean(b)).ratio()
return ratio >= threshold
+1 -1
View File
@@ -28,7 +28,7 @@ COUNTRY_TO_LANGUAGE: dict[str, str] = {"JP": "ja", "KR": "ko", "CN": "zh", "TW":
def parse_anilist_ref(value: Union[int, str]) -> Optional[tuple[str, int]]:
"""Split an AniList reference into its namespace and number.
A bare number is an AniList ID; ``mal:12345`` is a MyAnimeList ID, which AniList
A bare number is an AniList ID. ``mal:12345`` is a MyAnimeList ID, which AniList
resolves natively. Returns None for anything else.
"""
text = str(value).strip().lower()
+1 -1
View File
@@ -67,7 +67,7 @@ class IMDBProvider(MetadataProvider):
return True
def graphql(self, operation: str, query: str) -> Optional[dict]:
"""Run a persisted query, registering it with one POST the first time it is seen."""
"""Send a persisted query, and add it to the gateway with one POST if the gateway does not know its hash."""
extensions = {"persistedQuery": {"version": 1, "sha256Hash": hashlib.sha256(query.encode()).hexdigest()}}
# IMDb's GraphQL gateway decodes "+" literally, so these JSON params must carry no spaces
params = {
+2 -2
View File
@@ -128,8 +128,8 @@ class TMDBProvider(MetadataProvider):
def find_by_imdb_id(self, imdb_id: str, kind: str) -> Optional[ExternalIds]:
"""Look up TMDB/TVDB IDs from an IMDB ID using TMDB's /find endpoint.
When the requested kind has no results, the other kind is tried, so the returned
tmdb_kind can differ from the kind asked for. Returns None if the request fails or
When the requested kind has no results, unshackle tries the other kind, so the
returned tmdb_kind can differ from the kind asked for. Returns None if the request fails or
nothing matches.
"""
self.log.debug("Looking up IMDB ID %s on TMDB", imdb_id)
+4 -4
View File
@@ -11,7 +11,7 @@ from unshackle.core.providers._base import ExternalIds, MetadataProvider, Metada
def primary_language(data: dict) -> Optional[str]:
"""Search results spell the key primary_language, the extended record originalLanguage."""
"""Search results spell the field primary_language, the extended record originalLanguage."""
return data.get("primary_language") or data.get("originalLanguage") or None
@@ -34,7 +34,7 @@ def parse_int(value: Optional[str]) -> Optional[int]:
def ids_from_remote(remote_ids: Optional[list], tvdb_id: Optional[int]) -> ExternalIds:
"""Build ExternalIds from a TVDB remote_ids/remoteIds list."""
"""Assemble ExternalIds from a TVDB remote_ids/remoteIds list."""
ext = ExternalIds(tvdb_id=tvdb_id)
for entry in remote_ids or []:
source = (entry.get("sourceName") or "").lower()
@@ -49,7 +49,7 @@ def ids_from_remote(remote_ids: Optional[list], tvdb_id: Optional[int]) -> Exter
def pick_match(
results: list[dict], search_title: str, year: Optional[int]
) -> tuple[Optional[dict], Optional[str], float]:
"""Best title match among results, ignoring any whose year is more than a year out."""
"""The result whose title matches best, ignoring any whose year is more than a year out."""
best: Optional[dict] = None
best_title: Optional[str] = None
best_ratio = 0.0
@@ -274,7 +274,7 @@ class TVDBProvider(MetadataProvider):
return mapping
def find_by_imdb_id(self, imdb_id: str, kind: str) -> Optional[ExternalIds]:
"""Resolve a TVDB ID from an IMDb ID via /search/remoteid."""
"""Get a TVDB ID from an IMDb ID through /search/remoteid."""
results = self.api_get(f"/search/remoteid/{imdb_id}")
if not results:
self.log.debug("No TVDB results for IMDB ID %s", imdb_id)