Files
MediaManager/media_manager/common/models.py
Maximilian Dorninger 25cd4b0724 Refactor tv and movies (#526)
This PR refactors the movie and tv modules and adds a "common" module
for shared logic.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Dedicated import and metadata services for movies and TV;
completed-torrent detection and import flows.

* **Refactor**
* Shared media schemas, models, repository logic and base services
consolidated; movie/TV services and routes now delegate to specialised
import/metadata services.

* **Bug Fixes**
  * Fixed TV episode-count method name.

* **Chores**
  * Added .DS_Store to ignore list; added module comment.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-07 14:18:29 +02:00

35 lines
959 B
Python

from uuid import UUID
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column
from media_manager.torrent.models import Quality
class MediaMixin:
"""
Mixin for common media fields used by both Movies and TV Shows.
"""
id: Mapped[UUID] = mapped_column(primary_key=True)
external_id: Mapped[int]
metadata_provider: Mapped[str]
name: Mapped[str]
overview: Mapped[str]
year: Mapped[int | None]
library: Mapped[str] = mapped_column(default="Default")
original_language: Mapped[str | None] = mapped_column(default=None)
imdb_id: Mapped[str | None] = mapped_column(default=None)
class MediaFileMixin:
"""
Mixin for common media file fields used by both Movie files and Episode files.
"""
file_path_suffix: Mapped[str]
quality: Mapped[Quality]
torrent_id: Mapped[UUID | None] = mapped_column(
ForeignKey(column="torrent.id", ondelete="SET NULL"),
)