From d99b3f65f0d33b60b98ba1faeac3ed55ee114180 Mon Sep 17 00:00:00 2001 From: Brage Date: Tue, 18 Jul 2023 14:41:30 +0200 Subject: [PATCH] Added missing mal --- pyMetadata/sources/mal.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pyMetadata/sources/mal.py diff --git a/pyMetadata/sources/mal.py b/pyMetadata/sources/mal.py new file mode 100644 index 00000000..bc133a5b --- /dev/null +++ b/pyMetadata/sources/mal.py @@ -0,0 +1,29 @@ +from mal import * +from .result import Metadata, DataResult + +class metadata(): + name: str = None + + def __init__(self, name: str) -> None: + self.name = name + + def lookup(self) -> DataResult: + try: + search = AnimeSearch(self.name) + if (len(search.results) == 0): + return DataResult(statusType="IGNORE", errorMessage="No results") + anime = Anime(search.results[0].mal_id) + meta = Metadata( + title = anime.title, + altTitle = [ + anime.title_english, + *anime.title_synonyms + ], + cover = anime.image_url, + summary = anime.synopsis, + type = 'movie' if anime.type.lower() == 'movie' else 'serie', + genres = anime.genres, + ) + return DataResult("SUCCESS", None, meta) + except Exception as e: + return DataResult(statusType="ERROR", errorMessage=str(e)) \ No newline at end of file