Expose certifications and per-country release dates
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

TMDb's release_dates/content_ratings blocks were already fetched via
append_to_response but discarded at normalization -- every downstream
layer (ingestion write, repository read, schema, service) was unbuilt.
Adds the full pipeline: NormalizedReleaseDate + get_or_create_certification,
a shared polymorphic sync/read (movie and series both use it), and
MovieDetailOut/SeriesDetailOut certification + release_dates fields.

Series content_ratings has no date of its own, so each rating is anchored
to the show's first_air_date with release_type="tv".

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-06 04:07:18 -05:00
co-authored by Claude Sonnet 5
parent 340cadd99d
commit e1a36ce227
15 changed files with 510 additions and 5 deletions
+34
View File
@@ -6,13 +6,16 @@ from app.core.ids import aurora_id
from app.models.artwork import Artwork
from app.models.credit import Credit
from app.models.enums import ArtworkType
from app.models.movie import ReleaseDate
from app.models.video import Video
from app.schemas.common import (
ArtworkOut,
CastCreditOut,
CertificationOut,
CrewCreditOut,
ImagesOut,
PersonBriefOut,
ReleaseDateOut,
VideoOut,
)
@@ -70,6 +73,37 @@ def to_video_out(video: Video) -> VideoOut:
)
def to_release_date_out(release_date: ReleaseDate) -> ReleaseDateOut:
certification = None
if release_date.certification is not None:
certification = CertificationOut(
system=release_date.certification.system, rating=release_date.certification.rating
)
return ReleaseDateOut(
country_code=release_date.country_code,
release_date=release_date.release_date,
release_type=release_date.release_type,
certification=certification,
note=release_date.note,
)
def pick_certification(release_dates: list[ReleaseDate], *, preferred_country: str = "US") -> str | None:
"""The single rating a client wants when it isn't picking a country
itself -- TMDb's own site defaults to the US rating badge, so this
does too, falling back to the first country that has one at all."""
fallback: str | None = None
for rd in release_dates:
if rd.certification is None:
continue
if rd.country_code == preferred_country:
return rd.certification.rating
if fallback is None:
fallback = rd.certification.rating
return fallback
def split_credits(
credits_: list[Credit], profile_paths: dict | None = None
) -> tuple[list[CastCreditOut], list[CrewCreditOut]]: