From 53a2d953f860ee4142f9d89f7c30b97b9935c4a4 Mon Sep 17 00:00:00 2001 From: benex Date: Tue, 19 Nov 2024 14:05:53 +0300 Subject: [PATCH] feat: enable customization of the preview window --- fastanime/cli/interfaces/utils.py | 19 +++++++++++++++---- fastanime/cli/utils/utils.py | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fastanime/cli/interfaces/utils.py b/fastanime/cli/interfaces/utils.py index 492175f..4f28e8e 100644 --- a/fastanime/cli/interfaces/utils.py +++ b/fastanime/cli/interfaces/utils.py @@ -46,8 +46,12 @@ def aniskip(mal_id: int, episode: str): # NOTE: May change this to a temp dir but there were issues so later WORKING_DIR = APP_CACHE_DIR # tempfile.gettempdir() -HEADER_COLOR = 215, 0, 95 -SEPARATOR_COLOR = 208, 208, 208 +_HEADER_COLOR = os.environ.get("FASTANIME_PREVIEW_HEADER_COLOR", "215,0,95").split(",") +HEADER_COLOR = _HEADER_COLOR[0], _HEADER_COLOR[1], _HEADER_COLOR[2] +_SEPARATOR_COLOR = os.environ.get( + "FASTANIME_PREVIEW_SEPARATOR_COLOR", "208,208,208" +).split(",") +SEPARATOR_COLOR = _SEPARATOR_COLOR[0], _SEPARATOR_COLOR[1], _SEPARATOR_COLOR[2] SINGLE_QUOTE = "'" IMAGES_CACHE_DIR = os.path.join(WORKING_DIR, "images") if not os.path.exists(IMAGES_CACHE_DIR): @@ -65,7 +69,7 @@ def save_image_from_url(url: str, file_name: str): file_name: filename to use """ image = requests.get(url) - with open(os.path.join(IMAGES_CACHE_DIR,f"{file_name}.png"), "wb") as f: + with open(os.path.join(IMAGES_CACHE_DIR, f"{file_name}.png"), "wb") as f: f.write(image.content) @@ -76,7 +80,14 @@ def save_info_from_str(info: str, file_name: str): info: the information anilist has on the anime file_name: the filename to use """ - with open(os.path.join(ANIME_INFO_CACHE_DIR,file_name,), "w",encoding="utf-8") as f: + with open( + os.path.join( + ANIME_INFO_CACHE_DIR, + file_name, + ), + "w", + encoding="utf-8", + ) as f: f.write(info) diff --git a/fastanime/cli/utils/utils.py b/fastanime/cli/utils/utils.py index dee03a9..86c34fe 100644 --- a/fastanime/cli/utils/utils.py +++ b/fastanime/cli/utils/utils.py @@ -108,7 +108,7 @@ def format_bytes_to_human(num_of_bytes: float, suffix: str = "B"): return f"{num_of_bytes:.1f}Yi{suffix}" -def get_true_fg(string: str, r: int, g: int, b: int, bold: bool = True) -> str: +def get_true_fg(string: str, r, g, b, bold: bool = True) -> str: """Custom helper function that enables colored text in the terminal Args: