From b503cc87a9cb17dde3e2d6b5b61accf6174e30e6 Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Fri, 28 Feb 2025 13:12:23 -0800 Subject: [PATCH] feat(e621): add environment variable setter --- konawall/sources/e621.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/konawall/sources/e621.py b/konawall/sources/e621.py index c7d9d24..48f6de1 100644 --- a/konawall/sources/e621.py +++ b/konawall/sources/e621.py @@ -1,5 +1,6 @@ import requests import logging +import os from konawall.custom_print import kv_print from konawall.custom_errors import RequestFailed from konawall.module_loader import add_source @@ -13,7 +14,10 @@ Turn a list of tags and a count into a list of URLs to download from :returns: A list of URLs to download from """ def request_posts(count: int, tags: list, config) -> list: - api_key = config["e621_api_key"] + if "KONAWALL_E621_API_KEY" in os.environ: + api_key = os.environ["KONAWALL_E621_API_KEY"] + else: + api_key = config["e621_api_key"] logging.debug(f"request_posts() called with count={count}, tags=[{', '.join(tags)}]") # Make sure we get a different result every time by using "order:random" as a tag if "order:random" not in tags: