mirror of
https://github.com/kittywitch/konawall-py.git
synced 2026-02-09 04:19:19 -08:00
feat(e621): add environment variable setter
This commit is contained in:
parent
e426a3ee4e
commit
b503cc87a9
1 changed files with 5 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from konawall.custom_print import kv_print
|
from konawall.custom_print import kv_print
|
||||||
from konawall.custom_errors import RequestFailed
|
from konawall.custom_errors import RequestFailed
|
||||||
from konawall.module_loader import add_source
|
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
|
:returns: A list of URLs to download from
|
||||||
"""
|
"""
|
||||||
def request_posts(count: int, tags: list, config) -> list:
|
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)}]")
|
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
|
# Make sure we get a different result every time by using "order:random" as a tag
|
||||||
if "order:random" not in tags:
|
if "order:random" not in tags:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue