Add collection/franchise ingestion
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
Collections were bare stubs (name only) lazily created the moment a
movie's belongs_to_collection reference was seen. Adds a real
ingest_collection pipeline: TMDb's /collection/{id} for overview and
poster/backdrop artwork, plus ordered CollectionMovie membership --
linking only movies already ingested into Aurora, the same
never-fabricate-a-stub rule movie recommendations already follow.
get_or_create_collection now refreshes name/overview on an existing
stub instead of only creating, guarded so a bare movie-stub call
(overview=None) never clobbers real data a full ingestion already
filled in.
New POST /api/v1/admin/ingest/collection endpoint and
ingest_collection_task; GET /api/v1/collections/{id} needed no changes
since its read path (collection_service.py) already assembled the full
detail shape.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4af4ba40ef
commit
892f78016c
@@ -138,6 +138,61 @@ class NormalizedMovie:
|
||||
recommendation_external_ids: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class NormalizedCollection:
|
||||
external_id: str
|
||||
name: str
|
||||
overview: str | None
|
||||
artwork: list[NormalizedArtwork] = field(default_factory=list)
|
||||
# TMDb's "parts", ordered by release date rather than TMDb's own array
|
||||
# order (which isn't guaranteed to be chronological) -- see
|
||||
# normalize_collection.
|
||||
part_external_ids: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
def normalize_collection(raw: dict) -> NormalizedCollection:
|
||||
artwork: list[NormalizedArtwork] = []
|
||||
if raw.get("poster_path"):
|
||||
artwork.append(
|
||||
NormalizedArtwork(
|
||||
"poster",
|
||||
_image_url_required(raw["poster_path"]),
|
||||
raw["poster_path"],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
is_primary=True,
|
||||
)
|
||||
)
|
||||
if raw.get("backdrop_path"):
|
||||
artwork.append(
|
||||
NormalizedArtwork(
|
||||
"backdrop",
|
||||
_image_url_required(raw["backdrop_path"]),
|
||||
raw["backdrop_path"],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
is_primary=True,
|
||||
)
|
||||
)
|
||||
|
||||
parts = sorted(
|
||||
raw.get("parts") or [],
|
||||
key=lambda p: _parse_date(p.get("release_date")) or date.max,
|
||||
)
|
||||
|
||||
return NormalizedCollection(
|
||||
external_id=str(raw["id"]),
|
||||
name=raw["name"],
|
||||
overview=raw.get("overview") or None,
|
||||
artwork=artwork,
|
||||
part_external_ids=[str(p["id"]) for p in parts],
|
||||
)
|
||||
|
||||
|
||||
_STATUS_MAP = {
|
||||
"Rumored": "rumored",
|
||||
"Planned": "planned",
|
||||
|
||||
Reference in New Issue
Block a user