Refactored how parameters are passed to backend
This commit is contained in:
parent
a2571d5a06
commit
674b5767ff
@ -54,13 +54,6 @@ settings_encrypt = {
|
||||
"salt": "Generated from create_app.py"
|
||||
}
|
||||
|
||||
settings_credentials = {
|
||||
"danbooru_backend": {
|
||||
"username": None,
|
||||
"password": None
|
||||
}
|
||||
}
|
||||
|
||||
# Basic settings to configure the bot's behavior
|
||||
settings_behavior = {
|
||||
"max_size": 15*1024*1024,
|
||||
@ -87,6 +80,15 @@ settings_time = {
|
||||
"long_date_week": "%m/%d/%Y %I:%M%p, %A"
|
||||
}
|
||||
|
||||
settings_backend = {
|
||||
"danbooru_backend": {
|
||||
"username": None,
|
||||
"password": None,
|
||||
"tmp_dir": settings_behavior["tmp_dir"],
|
||||
"max_size": settings_behavior["max_size"]
|
||||
}
|
||||
}
|
||||
|
||||
banned_tags = (
|
||||
"guro", "scat", "yaoi", "implied_yaoi", "bara", "male_focus", "futanari"
|
||||
)
|
||||
|
@ -79,11 +79,11 @@ class downloader:
|
||||
# Limit for posts.json is 200
|
||||
limit=100
|
||||
|
||||
def __init__(self, backend_credentials, settings_behavior):
|
||||
def __init__(self, backend_credentials):
|
||||
self.username = backend_credentials["username"]
|
||||
self.password = backend_credentials["password"]
|
||||
self.max_size = settings_behavior["max_size"]
|
||||
self.tmp = settings_behavior["tmp_dir"]
|
||||
self.max_size = backend_credentials["max_size"]
|
||||
self.tmp = backend_credentials["tmp_dir"]
|
||||
|
||||
|
||||
def download_post(self, post):
|
||||
|
@ -144,11 +144,9 @@ class YandereBot:
|
||||
try:
|
||||
backend_s = picked_profile["backend"]
|
||||
backend = importlib.import_module(backend_s)
|
||||
backend_credentials = self.settings_credentials[backend_s]
|
||||
backend_credentials = self.settings_backend[backend_s]
|
||||
img = None
|
||||
downloader = backend.downloader(
|
||||
backend_credentials, self.settings_behavior
|
||||
)
|
||||
downloader = backend.downloader(backend_credentials)
|
||||
|
||||
img = downloader.fetch_post(picked_profile)
|
||||
|
||||
|
Reference in New Issue
Block a user