Type movie & all related types

This commit is contained in:
Zoe Roux 2025-05-08 01:31:41 +02:00
parent 7cef910323
commit 356b4c0c33
No known key found for this signature in database
11 changed files with 135 additions and 98 deletions

View File

@ -65,7 +65,7 @@ export const FullCollection = t.Intersect([
export type FullCollection = Prettify<typeof FullCollection.static>; export type FullCollection = Prettify<typeof FullCollection.static>;
export const SeedCollection = t.Composite([ export const SeedCollection = t.Composite([
t.Omit(BaseCollection, ["kind", "startAir", "endAir", "nextRefresh"]), t.Omit(BaseCollection, ["startAir", "endAir", "nextRefresh"]),
t.Object({ t.Object({
slug: t.String({ format: "slug" }), slug: t.String({ format: "slug" }),
originalLanguage: Language({ originalLanguage: Language({

View File

@ -72,7 +72,7 @@ export const FullMovie = t.Intersect([
export type FullMovie = Prettify<typeof FullMovie.static>; export type FullMovie = Prettify<typeof FullMovie.static>;
export const SeedMovie = t.Composite([ export const SeedMovie = t.Composite([
t.Omit(BaseMovie, ["kind", "nextRefresh"]), t.Omit(BaseMovie, ["nextRefresh"]),
t.Object({ t.Object({
slug: t.String({ format: "slug", examples: ["bubble"] }), slug: t.String({ format: "slug", examples: ["bubble"] }),
originalLanguage: Language({ originalLanguage: Language({

View File

@ -88,7 +88,7 @@ export const FullSerie = t.Intersect([
export type FullSerie = Prettify<typeof FullSerie.static>; export type FullSerie = Prettify<typeof FullSerie.static>;
export const SeedSerie = t.Composite([ export const SeedSerie = t.Composite([
t.Omit(BaseSerie, ["kind", "nextRefresh"]), t.Omit(BaseSerie, ["nextRefresh"]),
t.Object({ t.Object({
slug: t.String({ format: "slug" }), slug: t.String({ format: "slug" }),
originalLanguage: Language({ originalLanguage: Language({

View File

@ -3,3 +3,15 @@ indent-style = "tab"
[tool.pyright] [tool.pyright]
reportAbstractUsage = false reportAbstractUsage = false
reportUnannotatedClassAttribute = false
enableTypeIgnoreComments = true
reportIgnoreCommentWithoutRule = false
reportUnknownArgumentType = false
reportUnknownVariableType = false
reportMissingParameterType = false
reportUnknownParameterType = false
reportUnknownMemberType = false
reportAny = false
reportExplicitAny = false
reportMissingTypeStubs = false
reportUnknownLambdaType = false

View File

@ -1,32 +1,31 @@
from dataclasses import asdict, dataclass, field from __future__ import annotations
from typing import Optional
from providers.types.genre import Genre from langcodes import Language
from .metadataid import MetadataID
from ..utils import Model
from .genre import Genre
from .metadataid import MetadataId
@dataclass class Collection(Model):
class CollectionTranslation: slug: str
original_language: Language
genres: list[Genre]
rating: int | None
external_id: dict[str, MetadataId]
translations: dict[str, CollectionTranslation] = {}
class CollectionTranslation(Model):
name: str name: str
descrpition: Optional[str] latin_name: str | None
tagline: Optional[str] description: str | None
aliases: Optional[str] tagline: str | None
tags: Optional[str] aliases: list[str]
tags: list[str]
posters: list[str] posters: list[str]
thumbnails: list[str] thumbnails: list[str]
banner: list[str] banner: list[str]
logos: list[str] logos: list[str]
@dataclass
class Collection:
slug: str
original_language: str
genres: list[Genre]
rating: Optional[int]
external_id: dict[str, MetadataID]
translations: dict[str, CollectionTranslation] = field(default_factory=dict)
def to_kyoo(self):
return asdict(self)

View File

@ -25,6 +25,3 @@ class Genre(str, Enum):
POLITICS = "politics" POLITICS = "politics"
SOAP = "soap" SOAP = "soap"
TALK = "talk" TALK = "talk"
def to_kyoo(self):
return self.value

View File

@ -1,14 +1,13 @@
from typing import Optional
from ..utils import Model from ..utils import Model
class MetadataId(Model): class MetadataId(Model):
data_id: str data_id: str
link: Optional[str] = None link: str | None = None
class EpisodeId(Model): class EpisodeId(Model):
serie_id: str serie_id: str
season: Optional[int] season: int | None
episode: int episode: int
link: Optional[str] = None link: str | None = None

View File

@ -1,14 +1,16 @@
from dataclasses import asdict, dataclass, field from __future__ import annotations
from datetime import date from datetime import date
from typing import Optional
from enum import Enum from enum import Enum
from providers.utils import select_translation, select_image from langcodes import Language
from ..utils import Model
from .collection import Collection from .collection import Collection
from .genre import Genre from .genre import Genre
from .metadataid import MetadataId
from .staff import Staff
from .studio import Studio from .studio import Studio
from .metadataid import MetadataID
class Status(str, Enum): class Status(str, Enum):
@ -17,50 +19,43 @@ class Status(str, Enum):
PLANNED = "planned" PLANNED = "planned"
@dataclass class Movie(Model):
class MovieTranslation: slug: str
name: str original_language: Language | None
tagline: Optional[str] = None
tags: list[str] = field(default_factory=list)
overview: Optional[str] = None
posters: list[str] = field(default_factory=list)
logos: list[str] = field(default_factory=list)
trailers: list[str] = field(default_factory=list)
thumbnails: list[str] = field(default_factory=list)
@dataclass
class Movie:
original_language: Optional[str]
aliases: list[str]
air_date: Optional[date | int]
status: Status
rating: int
runtime: Optional[int]
studios: list[Studio]
genres: list[Genre] genres: list[Genre]
# TODO: handle staff rating: int | None
# staff: list[Staff] status: Status
external_id: dict[str, MetadataID] runtime: int | None
air_date: date | None
path: Optional[str] = None external_id: dict[str, MetadataId]
# The title of this show according to it's filename (None only for ease of use in providers) translations: dict[str, MovieTranslation] = {}
file_title: Optional[str] = None videos: list[str] = []
collections: list[Collection] = field(default_factory=list) collections: list[Collection] = []
translations: dict[str, MovieTranslation] = field(default_factory=dict) studios: list[Studio] = []
staff: list[Staff] = []
def to_kyoo(self):
trans = select_translation(self) or MovieTranslation(name=self.file_title or "") class MovieTranslation(Model):
return { name: str
**asdict(self), latin_name: str | None
**asdict(trans), description: str | None
"poster": select_image(self, "posters"), tagline: str | None
"thumbnail": select_image(self, "thumbnails"), aliases: list[str]
"logo": select_image(self, "logos"), tags: list[str]
"trailer": select_image(self, "trailers"),
"studio": next((x.to_kyoo() for x in self.studios), None), posters: list[str]
"genres": [x.to_kyoo() for x in self.genres], thumbnails: list[str]
"collections": None, banner: list[str]
"file_title": None, logos: list[str]
} trailers: list[str]
class SearchMovie(Model):
slug: str
name: str
description: str | None
air_date: date | None
poster: str
original_language: Language | None
external_id: dict[str, MetadataId]

View File

@ -0,0 +1,35 @@
from __future__ import annotations
from enum import Enum
from ..utils import Model
from .metadataid import MetadataId
class Role(str, Enum):
ACTOR = "actor"
DIRECTOR = "director"
WRITTER = "writter"
PRODUCER = "producer"
MUSIC = "music"
OTHER = "other"
class Staff(Model):
kind: Role
character: Character | None
staff: Person
class Character(Model):
name: str
latin_name: str | None
image: str | None
class Person(Model):
slug: str
name: str
latin_name: str | None
image: str | None
external_id: dict[str, MetadataId]

View File

@ -1,16 +1,15 @@
from dataclasses import asdict, dataclass, field from __future__ import annotations
from .metadataid import MetadataID from ..utils import Model
from .metadataid import MetadataId
@dataclass class Studio(Model):
class Studio: slug: str
external_id: dict[str, MetadataId]
translations: dict[str, StudioTranslations] = {}
class StudioTranslations(Model):
name: str name: str
logos: list[str] = field(default_factory=list) logo: str | None
external_id: dict[str, MetadataID] = field(default_factory=dict)
def to_kyoo(self):
return {
**asdict(self),
"logo": next(iter(self.logos), None),
}

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from typing import Any, Literal, Optional from typing import Any, Literal
from ..utils import Model from ..utils import Model
from .extra import ExtraKind from .extra import ExtraKind
@ -21,7 +21,7 @@ class VideoInfo(Model):
class Guess(Model, extra="allow"): class Guess(Model, extra="allow"):
title: str title: str
kind: Literal["episode"] | Literal["movie"] | Literal["extra"] kind: Literal["episode"] | Literal["movie"] | Literal["extra"]
extra_kind: Optional[ExtraKind] extra_kind: ExtraKind | None
years: list[int] years: list[int]
episodes: list[Guess.Episode] episodes: list[Guess.Episode]
external_id: dict[str, str] external_id: dict[str, str]
@ -31,11 +31,11 @@ class Guess(Model, extra="allow"):
history: list[Guess] = [] history: list[Guess] = []
class Episode(Model): class Episode(Model):
season: Optional[int] season: int | None
episode: int episode: int
Guess.model_rebuild() _ = Guess.model_rebuild()
class For(Model): class For(Model):
@ -65,13 +65,14 @@ class For(Model):
class Video(Model): class Video(Model):
path: str path: str
rendering: str rendering: str
part: Optional[int] part: int | None
version: int = 1 version: int = 1
guess: Guess guess: Guess
for_: list[ for_: list[
For.Slug | For.ExternalId | For.Movie | For.Episode | For.Order | For.Special For.Slug | For.ExternalId | For.Movie | For.Episode | For.Order | For.Special
] = [] ] = []
class VideoCreated(Resource): class VideoCreated(Resource):
guess: Guess guess: Guess
entries: list[Resource] entries: list[Resource]