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
@@ -7,6 +7,7 @@ from __future__ import annotations
|
||||
from datetime import date
|
||||
|
||||
from app.services.metadata.normalizer import (
|
||||
normalize_collection,
|
||||
normalize_movie,
|
||||
normalize_person,
|
||||
normalize_season,
|
||||
@@ -403,3 +404,50 @@ def test_normalize_season_maps_episode_crew_and_stills():
|
||||
def test_normalize_season_handles_episode_without_still():
|
||||
season = normalize_season(FAKE_SEASON)
|
||||
assert season.episodes[1].stills == []
|
||||
|
||||
|
||||
FAKE_COLLECTION = {
|
||||
"id": 2344,
|
||||
"name": "The Matrix Collection",
|
||||
"overview": "A group of films...",
|
||||
"poster_path": "/collection-poster.jpg",
|
||||
"backdrop_path": "/collection-backdrop.jpg",
|
||||
"parts": [
|
||||
{"id": 605, "title": "The Matrix Revolutions", "release_date": "2003-11-05"},
|
||||
{"id": 603, "title": "The Matrix", "release_date": "1999-03-30"},
|
||||
{"id": 604, "title": "The Matrix Reloaded", "release_date": "2003-05-15"},
|
||||
{"id": 999, "title": "Untitled Prequel", "release_date": ""},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_normalize_collection_maps_basic_fields():
|
||||
collection = normalize_collection(FAKE_COLLECTION)
|
||||
assert collection.external_id == "2344"
|
||||
assert collection.name == "The Matrix Collection"
|
||||
assert collection.overview == "A group of films..."
|
||||
|
||||
|
||||
def test_normalize_collection_maps_poster_and_backdrop_as_primary_artwork():
|
||||
collection = normalize_collection(FAKE_COLLECTION)
|
||||
poster = next(a for a in collection.artwork if a.artwork_type == "poster")
|
||||
backdrop = next(a for a in collection.artwork if a.artwork_type == "backdrop")
|
||||
assert poster.is_primary is True
|
||||
assert poster.url.endswith("/collection-poster.jpg")
|
||||
assert backdrop.is_primary is True
|
||||
assert backdrop.url.endswith("/collection-backdrop.jpg")
|
||||
|
||||
|
||||
def test_normalize_collection_orders_parts_by_release_date_not_array_order():
|
||||
collection = normalize_collection(FAKE_COLLECTION)
|
||||
# Input order is [605, 603, 604, 999] -- release-date order puts the
|
||||
# undated "999" entry last rather than fabricating a sort position.
|
||||
assert collection.part_external_ids == ["603", "604", "605", "999"]
|
||||
|
||||
|
||||
def test_normalize_collection_handles_missing_overview_and_parts():
|
||||
minimal = {"id": 1, "name": "Minimal Collection"}
|
||||
collection = normalize_collection(minimal)
|
||||
assert collection.overview is None
|
||||
assert collection.artwork == []
|
||||
assert collection.part_external_ids == []
|
||||
|
||||
Reference in New Issue
Block a user