mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Type Video
in the scanner
This commit is contained in:
parent
742ae4e771
commit
a6f48d1f9a
@ -21,11 +21,15 @@ export const Guess = t.Recursive((Self) =>
|
||||
t.Object(
|
||||
{
|
||||
title: t.String(),
|
||||
year: t.Optional(t.Array(t.Integer(), { default: [] })),
|
||||
season: t.Optional(t.Array(t.Integer(), { default: [] })),
|
||||
episode: t.Optional(t.Array(t.Integer(), { default: [] })),
|
||||
kind: t.Optional(t.UnionEnum(["episode", "movie", "extra"])),
|
||||
extraKind: t.Optional(ExtraType),
|
||||
years: t.Optional(t.Array(t.Integer(), { default: [] })),
|
||||
episodes: t.Optional(
|
||||
t.Array(
|
||||
t.Object({ season: t.Nullable(t.Integer()), episode: t.Integer() }),
|
||||
{ default: [] },
|
||||
),
|
||||
),
|
||||
externalId: t.Optional(ExternalIds),
|
||||
|
||||
from: t.String({
|
||||
|
@ -6,7 +6,7 @@ from logging import getLogger
|
||||
from typing import Optional
|
||||
|
||||
from .utils import format_date
|
||||
from .models.videos import VideoInfo
|
||||
from .models.videos import VideoInfo, Video
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
@ -44,7 +44,7 @@ class KyooClient:
|
||||
async def create_videos(self, videos: list[Video]):
|
||||
async with self._client.post(
|
||||
f"{self._url}/videos",
|
||||
json=[x.model_dump() for x in videos]
|
||||
json=[x.model_dump_json() for x in videos],
|
||||
) as r:
|
||||
r.raise_for_status()
|
||||
|
||||
|
11
scanner/scanner/models/extra.py
Normal file
11
scanner/scanner/models/extra.py
Normal file
@ -0,0 +1,11 @@
|
||||
from typing import Literal
|
||||
|
||||
type ExtraKind = (
|
||||
Literal["other"] |
|
||||
Literal["trailer"] |
|
||||
Literal["interview"] |
|
||||
Literal["behind-the-scene"] |
|
||||
Literal["deleted-scene"] |
|
||||
Literal["blooper"]
|
||||
)
|
||||
|
@ -1,8 +1,14 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from ..utils import Model
|
||||
|
||||
|
||||
@dataclass
|
||||
class MetadataID:
|
||||
class MetadataId(Model):
|
||||
data_id: str
|
||||
link: Optional[str]
|
||||
|
||||
|
||||
class EpisodeId(Model):
|
||||
serie_id: str
|
||||
season: Optional[int]
|
||||
episode: int
|
||||
link: Optional[str]
|
||||
|
@ -1,7 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ..utils import Model
|
||||
from typing import Optional
|
||||
from .extra import ExtraKind
|
||||
from .metadataid import MetadataId, EpisodeId
|
||||
from typing import Optional, Literal
|
||||
|
||||
|
||||
class Resource(Model):
|
||||
@ -13,3 +15,57 @@ class VideoInfo(Model):
|
||||
paths: set[str]
|
||||
unmatched: set[str]
|
||||
guesses: dict[str, dict[str, Resource]]
|
||||
|
||||
|
||||
class Guess(Model):
|
||||
title: str
|
||||
kind: Literal["episode"] | Literal["movie"] | Literal["extra"]
|
||||
extraKind: Optional[ExtraKind]
|
||||
years: list[int]
|
||||
episodes: list[Guess.Episode]
|
||||
external_id: dict[str, MetadataId | EpisodeId]
|
||||
|
||||
from_: str
|
||||
history: list[Guess]
|
||||
|
||||
class Episode(Model):
|
||||
season: Optional[int]
|
||||
episode: int
|
||||
|
||||
|
||||
Guess.model_rebuild()
|
||||
|
||||
|
||||
class For(Model):
|
||||
class Slug(Model):
|
||||
slug: str
|
||||
|
||||
class ExternalId(Model):
|
||||
external_id: dict[str, MetadataId | EpisodeId]
|
||||
|
||||
class Movie(Model):
|
||||
movie: str
|
||||
|
||||
class Episode(Model):
|
||||
serie: str
|
||||
season: int
|
||||
episode: int
|
||||
|
||||
class Order(Model):
|
||||
serie: str
|
||||
order: float
|
||||
|
||||
class Special(Model):
|
||||
serie: int
|
||||
special: int
|
||||
|
||||
|
||||
class Video(Model):
|
||||
path: str
|
||||
rendering: str
|
||||
part: Optional[int]
|
||||
version: int = 1
|
||||
guess: Guess
|
||||
for_: Optional[
|
||||
For.Slug | For.ExternalId | For.Movie | For.Episode | For.Order | For.Special
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user