Add watch providers (where to stream/rent/buy)
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
New TMDb integration end to end: append_to_response "watch/providers", normalizer parsing grouped by country/monetization type, a WatchProvider catalog entry (external-id keyed, same get_or_create pattern as Company/ Collection/Person) + polymorphic WatchProviderOffering table (new migration 0002), ingestion write (including provider logos via the existing Artwork table), and API exposure -- embedded on movie/series detail plus a dedicated /watch-providers sub-route, shaped to mirror TMDb's own response for easy porting. Note: this data comes from JustWatch via TMDb and carries its own attribution requirement separate from TMDb's general one -- flagged in docs/api.md, must be satisfied before showing this in the frontend. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
74ebad379a
commit
6c95e18aad
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.ids import aurora_id
|
||||
from app.models.artwork import Artwork
|
||||
from app.models.credit import Credit
|
||||
@@ -9,6 +11,8 @@ from app.models.enums import ArtworkType
|
||||
from app.models.movie import MovieAlternateTitle, ReleaseDate
|
||||
from app.models.tv import SeriesAlternateTitle
|
||||
from app.models.video import Video
|
||||
from app.models.watch_provider import WatchProviderOffering
|
||||
from app.repositories import polymorphic
|
||||
from app.schemas.common import (
|
||||
AlternateTitleOut,
|
||||
ArtworkOut,
|
||||
@@ -19,6 +23,8 @@ from app.schemas.common import (
|
||||
PersonBriefOut,
|
||||
ReleaseDateOut,
|
||||
VideoOut,
|
||||
WatchProviderOut,
|
||||
WatchProviderRegionOut,
|
||||
)
|
||||
|
||||
|
||||
@@ -110,6 +116,34 @@ def pick_certification(release_dates: list[ReleaseDate], *, preferred_country: s
|
||||
return fallback
|
||||
|
||||
|
||||
async def build_watch_providers_out(
|
||||
session: AsyncSession, offerings: list[WatchProviderOffering]
|
||||
) -> dict[str, WatchProviderRegionOut]:
|
||||
out: dict[str, WatchProviderRegionOut] = {}
|
||||
logo_cache: dict[object, str | None] = {}
|
||||
for row in offerings:
|
||||
region = out.get(row.country_code)
|
||||
if region is None:
|
||||
region = WatchProviderRegionOut(link=row.link)
|
||||
out[row.country_code] = region
|
||||
elif region.link is None and row.link is not None:
|
||||
region.link = row.link
|
||||
|
||||
wp = row.watch_provider
|
||||
if wp.id not in logo_cache:
|
||||
logos = await polymorphic.get_artwork(session, "watch_provider", wp.id, ArtworkType.LOGO)
|
||||
logo_cache[wp.id] = primary_artwork_path(logos, ArtworkType.LOGO)
|
||||
|
||||
entry = WatchProviderOut(
|
||||
id=aurora_id("watch_provider", str(wp.id)),
|
||||
name=wp.name,
|
||||
logo_path=logo_cache[wp.id],
|
||||
display_priority=row.display_priority,
|
||||
)
|
||||
getattr(region, row.monetization_type).append(entry)
|
||||
return out
|
||||
|
||||
|
||||
def split_credits(
|
||||
credits_: list[Credit], profile_paths: dict | None = None
|
||||
) -> tuple[list[CastCreditOut], list[CrewCreditOut]]:
|
||||
|
||||
Reference in New Issue
Block a user