mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 07:20:33 -04:00
Add stopgap mesure for collections missing translations
This commit is contained in:
parent
f8c6602604
commit
b228fbb35c
@ -1,7 +1,8 @@
|
|||||||
import os
|
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from providers.utils import ProviderError, select_translation, select_image
|
||||||
|
|
||||||
from .metadataid import MetadataID
|
from .metadataid import MetadataID
|
||||||
|
|
||||||
|
|
||||||
@ -20,14 +21,15 @@ class Collection:
|
|||||||
translations: dict[str, CollectionTranslation] = field(default_factory=dict)
|
translations: dict[str, CollectionTranslation] = field(default_factory=dict)
|
||||||
|
|
||||||
def to_kyoo(self):
|
def to_kyoo(self):
|
||||||
# For now, the API of kyoo only support one language so we remove the others.
|
trans = select_translation(self)
|
||||||
default_language = os.environ["LIBRARY_LANGUAGES"].split(",")[0]
|
if trans is None:
|
||||||
|
raise ProviderError(
|
||||||
|
"Could not find translations for the collection. Aborting"
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
**asdict(self),
|
**asdict(self),
|
||||||
**asdict(self.translations[default_language]),
|
**asdict(trans),
|
||||||
"poster": next(iter(self.translations[default_language].posters), None),
|
"poster": select_image(self, "posters"),
|
||||||
"thumbnail": next(
|
"thumbnail": select_image(self, "thumbnails"),
|
||||||
iter(self.translations[default_language].thumbnails), None
|
"logo": select_image(self, "logos"),
|
||||||
),
|
|
||||||
"logo": next(iter(self.translations[default_language].logos), None),
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user