Files
Aurora-Core/app/models/artwork.py
T
NixReaperandClaude Sonnet 5 c20df1c503
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
Initial Aurora Core 0.1 implementation
Production-grade media metadata backend per docs/aurora-core-spec.md:
Aurora-owned UUIDv7 identity system, normalized movie/TV/people/credits
schema, provider abstraction with a TMDb adapter, an idempotent async
ingestion pipeline (normalize -> match -> upsert -> provenance), a
Postgres FTS/trigram search layer, a stateless FastAPI v1 API with
Redis caching/rate-limiting, arq workers, dev/prod Docker Compose
topologies, unit + integration + load tests, CI, and architecture/
database/API/ERD documentation.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-04 17:34:03 -05:00

53 lines
2.1 KiB
Python

"""Artwork as a first-class entity (section 10) — never a `poster_url`
column on media tables, so provenance/licensing can be tracked per asset."""
from __future__ import annotations
import uuid
from sqlalchemy import Boolean, Float, ForeignKey, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
from app.models.enums import ArtworkType
from app.models.provider import Provider
class Artwork(Base, UUIDPrimaryKeyMixin, TimestampMixin):
__tablename__ = "artwork"
__table_args__ = (
Index("ix_artwork_entity", "entity_type", "entity_id", "artwork_type"),
)
# Polymorphic target: "movie", "series", "season", "episode", "person",
# "company", "collection".
entity_type: Mapped[str] = mapped_column(String(30), nullable=False)
entity_id: Mapped[uuid.UUID] = mapped_column(nullable=False)
artwork_type: Mapped[ArtworkType] = mapped_column(nullable=False)
language_code: Mapped[str | None] = mapped_column(
ForeignKey("languages.code"), nullable=True
)
width: Mapped[int | None] = mapped_column(Integer, nullable=True)
height: Mapped[int | None] = mapped_column(Integer, nullable=True)
aspect_ratio: Mapped[float | None] = mapped_column(Float, nullable=True)
vote_average: Mapped[float | None] = mapped_column(Float, nullable=True)
is_primary: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
provider_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("providers.id", ondelete="CASCADE"), nullable=False
)
provider_asset_id: Mapped[str | None] = mapped_column(String(200), nullable=True)
original_url: Mapped[str] = mapped_column(String(1000), nullable=False)
local_path: Mapped[str | None] = mapped_column(String(1000), nullable=True)
checksum: Mapped[str | None] = mapped_column(String(128), nullable=True)
attribution: Mapped[str | None] = mapped_column(Text, nullable=True)
license: Mapped[str | None] = mapped_column(Text, nullable=True)
provider: Mapped[Provider] = relationship()
__all__ = ["Artwork"]