goon/app/models/movie.py
goon-foss a4486980a4 style: myslniki em/en z komentarzy i docstringow (calosc repo)
1745 wystapien w 291 plikach (backend, scripts, mobile). Dominowal jeden ksztalt,
' — ' laczace zdania, wiec poszedl przecinek; myslnik otwierajacy mysl zdjety;
zakresy 0–5 i A–Z na dywiz.

Podzial komentarz/kod robil skaner stanow, nie regex, zeby nie ruszyc myslnika
stojacego w stringu albo w wyrazeniu regularnym. Potwierdzone maszynowo: po wycieciu
komentarzy z wersji HEAD i z dysku obie sa identyczne we wszystkich 291 plikach,
czyli poza komentarzami nie zmienilo sie nic. 233 pliki .py parsuja sie bez bledu,
tsc ma te same 11 bledow w tych samych 3 plikach co przed zmiana.

Dwie rzeczy wymagaly poprawki po automacie: wyrownane listy definicji, gdzie myslnik
byl separatorem kolumny (37 miejsc, kolumna przywrocona), i trzy przeniesienia mysli
do nowej linii, gdzie zostawal wiszacy przecinek na poczatku (poprawione recznie).

Bundla nie republikuje: Hermes i tak nie niesie komentarzy, wiec dla uzytkownika
to zero zmiany.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 11:51:57 +02:00

116 lines
4.4 KiB
Python

"""Movies, full-length adult films (paradisehill primary, mirrory z innych tube'ów).
Movies vs Scenes:
- Scena: 5-30min, single performance, jeden moment w czasie. Kanon: TPDB/StashDB.
- Movie: 60-180min, multi-chapter, full DVD/release. Kanon: paradisehill + mirrory.
Performers/Studios/Tags reusable, ten sam ludzie/studia mogą występować w obu.
"""
from __future__ import annotations
import uuid
from datetime import date, datetime
from sqlalchemy import (
Date,
DateTime,
Float,
ForeignKey,
Integer,
String,
Text,
UniqueConstraint,
func,
)
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin, UUIDPKMixin
class Movie(UUIDPKMixin, TimestampMixin, Base):
__tablename__ = "movies"
title: Mapped[str] = mapped_column(String(512), nullable=False)
title_normalized: Mapped[str] = mapped_column(String(512), nullable=False, index=True)
slug: Mapped[str | None] = mapped_column(String(512), index=True)
release_year: Mapped[int | None] = mapped_column(Integer, index=True)
release_date: Mapped[date | None] = mapped_column(Date, index=True)
studio_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True), ForeignKey("studios.id", ondelete="SET NULL"), index=True
)
director: Mapped[str | None] = mapped_column(String(256))
country: Mapped[str | None] = mapped_column(String(64))
duration_sec: Mapped[int | None] = mapped_column(Integer)
description: Mapped[str | None] = mapped_column(Text)
poster_url: Mapped[str | None] = mapped_column(String(2048))
backdrop_url: Mapped[str | None] = mapped_column(String(2048))
rating: Mapped[float | None] = mapped_column(Float)
class MovieExternalRef(Base):
__tablename__ = "movie_external_refs"
source_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("sources.id", ondelete="CASCADE"), primary_key=True
)
external_id: Mapped[str] = mapped_column(String(256), primary_key=True)
movie_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("movies.id", ondelete="CASCADE"), nullable=False, index=True
)
confidence: Mapped[float] = mapped_column(Float, nullable=False, default=1.0, server_default="1.0")
url: Mapped[str | None] = mapped_column(String(1024))
first_seen: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), nullable=False
)
last_seen: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), nullable=False
)
class MoviePerformer(Base):
__tablename__ = "movie_performers"
movie_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("movies.id", ondelete="CASCADE"), primary_key=True
)
performer_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("performers.id", ondelete="CASCADE"), primary_key=True
)
role: Mapped[str | None] = mapped_column(String(64))
position: Mapped[int | None] = mapped_column(Integer)
as_alias: Mapped[str | None] = mapped_column(String(256))
class MovieTag(Base):
__tablename__ = "movie_tags"
movie_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("movies.id", ondelete="CASCADE"), primary_key=True
)
tag_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("tags.id", ondelete="CASCADE"), primary_key=True
)
source_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True), ForeignKey("sources.id", ondelete="SET NULL")
)
class MovieChapter(UUIDPKMixin, Base):
"""Optional chapter markers dla filmów (paradisehill czasem dzieli na sceny)."""
__tablename__ = "movie_chapters"
__table_args__ = (
UniqueConstraint("movie_id", "chapter_index", name="uq_movie_chapters_movie_id_chapter_index"),
)
movie_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("movies.id", ondelete="CASCADE"), nullable=False, index=True
)
chapter_index: Mapped[int] = mapped_column(Integer, nullable=False)
title: Mapped[str | None] = mapped_column(String(512))
start_sec: Mapped[int | None] = mapped_column(Integer)
end_sec: Mapped[int | None] = mapped_column(Integer)
scene_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True), ForeignKey("scenes.id", ondelete="SET NULL")
)