mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Handle missing translations for series
This commit is contained in:
parent
710e3cf10b
commit
ca7dd81452
@ -117,7 +117,7 @@ class Matcher:
|
|||||||
)
|
)
|
||||||
episode.path = path
|
episode.path = path
|
||||||
logger.debug("Got episode: %s", episode)
|
logger.debug("Got episode: %s", episode)
|
||||||
episode.show_id = await self.create_or_get_show(episode)
|
episode.show_id = await self.create_or_get_show(episode, title)
|
||||||
|
|
||||||
if episode.season_number is not None:
|
if episode.season_number is not None:
|
||||||
episode.season_id = await self.register_seasons(
|
episode.season_id = await self.register_seasons(
|
||||||
@ -141,7 +141,7 @@ class Matcher:
|
|||||||
provider_id = collection.external_id[self._provider.name].data_id
|
provider_id = collection.external_id[self._provider.name].data_id
|
||||||
return await create_collection(provider_id)
|
return await create_collection(provider_id)
|
||||||
|
|
||||||
async def create_or_get_show(self, episode: Episode) -> str:
|
async def create_or_get_show(self, episode: Episode, fallback_name: str) -> str:
|
||||||
@cache(ttl=timedelta(days=1), cache=self._show_cache)
|
@cache(ttl=timedelta(days=1), cache=self._show_cache)
|
||||||
async def create_show(_: str):
|
async def create_show(_: str):
|
||||||
# TODO: Check if a show with the same metadata id exists already on kyoo.
|
# TODO: Check if a show with the same metadata id exists already on kyoo.
|
||||||
@ -152,6 +152,7 @@ class Matcher:
|
|||||||
if isinstance(episode.show, PartialShow)
|
if isinstance(episode.show, PartialShow)
|
||||||
else episode.show
|
else episode.show
|
||||||
)
|
)
|
||||||
|
show.file_title = fallback_name
|
||||||
# TODO: collections
|
# TODO: collections
|
||||||
logger.debug("Got show: %s", episode)
|
logger.debug("Got show: %s", episode)
|
||||||
ret = await self._client.post("show", data=show.to_kyoo())
|
ret = await self._client.post("show", data=show.to_kyoo())
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import os
|
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
from providers.utils import select_translation, select_image
|
||||||
|
|
||||||
from .genre import Genre
|
from .genre import Genre
|
||||||
from .studio import Studio
|
from .studio import Studio
|
||||||
from .season import Season
|
from .season import Season
|
||||||
@ -20,14 +21,14 @@ class Status(str, Enum):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class ShowTranslation:
|
class ShowTranslation:
|
||||||
name: str
|
name: str
|
||||||
tagline: Optional[str]
|
tagline: Optional[str] = None
|
||||||
tags: list[str]
|
tags: list[str] = []
|
||||||
overview: Optional[str]
|
overview: Optional[str] = None
|
||||||
|
|
||||||
posters: list[str]
|
posters: list[str] = []
|
||||||
logos: list[str]
|
logos: list[str] = []
|
||||||
trailers: list[str]
|
trailers: list[str] = []
|
||||||
thumbnails: list[str]
|
thumbnails: list[str] = []
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -46,20 +47,21 @@ class Show:
|
|||||||
external_id: dict[str, MetadataID]
|
external_id: dict[str, MetadataID]
|
||||||
|
|
||||||
translations: dict[str, ShowTranslation] = field(default_factory=dict)
|
translations: dict[str, ShowTranslation] = field(default_factory=dict)
|
||||||
|
# The title of this show according to it's filename (None only for ease of use in providers)
|
||||||
|
file_title: Optional[str] = None
|
||||||
|
|
||||||
def to_kyoo(self):
|
def to_kyoo(self):
|
||||||
from providers.utils import select_image
|
trans = select_translation(self) or ShowTranslation(name=self.file_title or "")
|
||||||
|
|
||||||
# For now, the API of kyoo only support one language so we remove the others.
|
|
||||||
default_language = os.environ["LIBRARY_LANGUAGES"].split(",")[0]
|
|
||||||
return {
|
return {
|
||||||
**asdict(self),
|
**asdict(self),
|
||||||
**asdict(self.translations[default_language]),
|
**asdict(trans),
|
||||||
|
"rating": self.rating or 0,
|
||||||
"studio": next((x.to_kyoo() for x in self.studios), None),
|
"studio": next((x.to_kyoo() for x in self.studios), None),
|
||||||
"seasons": None,
|
"seasons": None,
|
||||||
"poster": select_image(self, "posters"),
|
"poster": select_image(self, "posters"),
|
||||||
"thumbnail": select_image(self, "thumbnails"),
|
"thumbnail": select_image(self, "thumbnails"),
|
||||||
"logo": select_image(self, "logos"),
|
"logo": select_image(self, "logos"),
|
||||||
"trailer": next(iter(self.translations[default_language].trailers), None),
|
"trailer": next(iter(trans.trailers), None),
|
||||||
"genres": [x.to_kyoo() for x in self.genres],
|
"genres": [x.to_kyoo() for x in self.genres],
|
||||||
|
"file_title": None,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user