mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-07-31 00:56:16 -04:00
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 -->
129 lines
2.6 KiB
Python
129 lines
2.6 KiB
Python
import typing
|
|
import uuid
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from media_manager.common.schemas import BaseMedia, BaseMediaFile
|
|
from media_manager.torrent.models import Quality
|
|
from media_manager.torrent.schemas import TorrentId, TorrentStatus
|
|
|
|
ShowId = typing.NewType("ShowId", UUID)
|
|
SeasonId = typing.NewType("SeasonId", UUID)
|
|
EpisodeId = typing.NewType("EpisodeId", UUID)
|
|
|
|
SeasonNumber = typing.NewType("SeasonNumber", int)
|
|
EpisodeNumber = typing.NewType("EpisodeNumber", int)
|
|
|
|
|
|
class Episode(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: EpisodeId = Field(default_factory=lambda: EpisodeId(uuid.uuid4()))
|
|
number: EpisodeNumber
|
|
external_id: int
|
|
title: str
|
|
overview: str | None = None
|
|
|
|
|
|
class Season(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: SeasonId = Field(default_factory=lambda: SeasonId(uuid.uuid4()))
|
|
number: SeasonNumber
|
|
|
|
name: str
|
|
overview: str
|
|
|
|
external_id: int
|
|
|
|
episodes: list[Episode]
|
|
|
|
|
|
class Show(BaseMedia):
|
|
id: ShowId = Field(default_factory=lambda: ShowId(uuid.uuid4()))
|
|
|
|
ended: bool = False
|
|
continuous_download: bool = False
|
|
|
|
seasons: list[Season]
|
|
|
|
|
|
class EpisodeFile(BaseMediaFile):
|
|
episode_id: EpisodeId
|
|
|
|
|
|
class PublicEpisodeFile(EpisodeFile):
|
|
downloaded: bool = False
|
|
|
|
|
|
class RichSeasonTorrent(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
torrent_id: TorrentId
|
|
torrent_title: str
|
|
status: TorrentStatus
|
|
quality: Quality
|
|
imported: bool
|
|
usenet: bool
|
|
|
|
file_path_suffix: str
|
|
seasons: list[SeasonNumber]
|
|
episodes: list[EpisodeNumber]
|
|
|
|
|
|
class RichShowTorrent(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
show_id: ShowId
|
|
name: str
|
|
year: int | None
|
|
metadata_provider: str
|
|
torrents: list[RichSeasonTorrent]
|
|
|
|
|
|
class PublicEpisode(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
id: EpisodeId
|
|
number: EpisodeNumber
|
|
|
|
downloaded: bool = False
|
|
title: str
|
|
overview: str | None = None
|
|
|
|
external_id: int
|
|
|
|
|
|
class PublicSeason(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: SeasonId
|
|
number: SeasonNumber
|
|
|
|
downloaded: bool = False
|
|
name: str
|
|
overview: str
|
|
|
|
external_id: int
|
|
|
|
episodes: list[PublicEpisode]
|
|
|
|
|
|
class PublicShow(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: ShowId
|
|
|
|
name: str
|
|
overview: str
|
|
year: int | None
|
|
|
|
external_id: int
|
|
metadata_provider: str
|
|
|
|
ended: bool = False
|
|
continuous_download: bool = False
|
|
library: str
|
|
|
|
seasons: list[PublicSeason]
|