Removed hardcoded url
This commit is contained in:
parent
d2378a1e5b
commit
2dd89995e1
@ -76,14 +76,16 @@ class downloader:
|
|||||||
password = None
|
password = None
|
||||||
max_size = None
|
max_size = None
|
||||||
tmp = None
|
tmp = None
|
||||||
# Limit for posts.json is 200
|
url = ""
|
||||||
limit=100
|
api_endpoint = "posts.json?random=true&limit=100"
|
||||||
|
api_tags = "&tags={}"
|
||||||
|
|
||||||
def __init__(self, backend_credentials):
|
def __init__(self, backend_credentials):
|
||||||
self.username = backend_credentials["username"]
|
self.username = backend_credentials["username"]
|
||||||
self.password = backend_credentials["password"]
|
self.password = backend_credentials["password"]
|
||||||
self.max_size = backend_credentials["max_size"]
|
self.max_size = backend_credentials["max_size"]
|
||||||
self.tmp = backend_credentials["tmp_dir"]
|
self.tmp = backend_credentials["tmp_dir"]
|
||||||
|
self.url = backend_credentials["url"]
|
||||||
|
|
||||||
|
|
||||||
def download_post(self, post):
|
def download_post(self, post):
|
||||||
@ -105,11 +107,11 @@ class downloader:
|
|||||||
def fetch_post(self, profile):
|
def fetch_post(self, profile):
|
||||||
# Search ratings: s=safe, e=nsfw
|
# Search ratings: s=safe, e=nsfw
|
||||||
# base_url = "https://danbooru.donmai.us/posts.json?random=true&tags={}&rating=e&limit=1"
|
# 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"]
|
tags = profile["tags"]
|
||||||
search_url = "https://danbooru.donmai.us/posts.json?random=true&limit={}".format(self.limit)
|
|
||||||
if tags and not random_tag(*tags):
|
if tags and not random_tag(*tags):
|
||||||
search_tags = "+".join(tags)
|
search_tags = "+".join(tags)
|
||||||
search_url = "{}&tags={}".format(search_url, search_tags)
|
search_url += self.api_tags.format(search_tags)
|
||||||
|
|
||||||
search_request = None
|
search_request = None
|
||||||
if self.username and self.password:
|
if self.username and self.password:
|
||||||
|
Reference in New Issue
Block a user