Removed hardcoded url

This commit is contained in:
Anon 2022-10-09 22:14:27 -07:00
parent d2378a1e5b
commit 2dd89995e1

View File

@ -76,14 +76,16 @@ class downloader:
password = None
max_size = None
tmp = None
# Limit for posts.json is 200
limit=100
url = ""
api_endpoint = "posts.json?random=true&limit=100"
api_tags = "&tags={}"
def __init__(self, backend_credentials):
self.username = backend_credentials["username"]
self.password = backend_credentials["password"]
self.max_size = backend_credentials["max_size"]
self.tmp = backend_credentials["tmp_dir"]
self.url = backend_credentials["url"]
def download_post(self, post):
@ -105,11 +107,11 @@ class downloader:
def fetch_post(self, profile):
# Search ratings: s=safe, e=nsfw
# base_url = "https://danbooru.donmai.us/posts.json?random=true&tags={}&rating=e&limit=1"
search_url = "/".join((self.url, self.api_endpoint))
tags = profile["tags"]
search_url = "https://danbooru.donmai.us/posts.json?random=true&limit={}".format(self.limit)
if tags and not random_tag(*tags):
search_tags = "+".join(tags)
search_url = "{}&tags={}".format(search_url, search_tags)
search_url += self.api_tags.format(search_tags)
search_request = None
if self.username and self.password: