From a53767bf74ca5c096306196dcd6c604f5d680f3f Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sat, 18 Feb 2023 16:29:44 +0100 Subject: [PATCH] update api template with type annotations [CI SKIP] Signed-off-by: Ivan Schaller --- contrib/api_template.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/api_template.py b/contrib/api_template.py index 89ed331..0098268 100644 --- a/contrib/api_template.py +++ b/contrib/api_template.py @@ -1,3 +1,5 @@ +from typing import List, Dict, Union + # api template for manga-dlp @@ -23,7 +25,7 @@ class YourAPI: api_base_url = "https://api.mangadex.org" img_base_url = "https://uploads.mangadex.org" - def __init__(self, url_uuid, language, forcevol): + def __init__(self, url_uuid: str, language: str, forcevol: bool): """get infos to initiate class.""" self.api_name = "Your API Name" @@ -35,7 +37,7 @@ class YourAPI: self.manga_uuid = "abc" self.manga_title = "abc" self.chapter_list = ["1", "2", "2.1", "5", "10"] - self.manga_chapter_data = { # example data + self.manga_chapter_data: Dict[str, Dict[str, str | int]] = { # example data "1": { "uuid": "abc", "volume": "1", @@ -50,7 +52,7 @@ class YourAPI: }, } # or with --forcevol - self.manga_chapter_data = { + self.manga_chapter_data: Dict[str, Dict[str, str | int]] = { "1:1": { "uuid": "abc", "volume": "1", @@ -65,7 +67,7 @@ class YourAPI: }, } - def get_chapter_images(chapter: str, download_wait: float) -> list: + def get_chapter_images(self, chapter: str, wait_time: float) -> List[str]: """Get chapter images as a list (full links). Args: @@ -82,7 +84,7 @@ class YourAPI: "https://abc.def/image/12345.png", ] - def create_metadata(chapter: str) -> dict: + def create_metadata(self, chapter: str) -> Dict[str, Union[str, int, None]]: """Get metadata with correct keys for ComicInfo.xml. Provide as much metadata as possible. empty/false values will be ignored. @@ -95,7 +97,7 @@ class YourAPI: """ # metadata types. have to be valid # {key: (type, default value, valid values)} - { + metadata_types = { "Title": (str, None, []), "Series": (str, None, []), "Number": (str, None, []),