diff --git a/src/danbooru_backend.py b/src/danbooru_backend.py index 5882dcc..3aaa79e 100644 --- a/src/danbooru_backend.py +++ b/src/danbooru_backend.py @@ -28,11 +28,9 @@ def random_tag(*tags): def collect_tags(post): - tag_response = [] - for tag_type in "tag_string", "tag_string_general": - if tag_type in post: - tag_response.append(post[tag_type].strip()) - return " ".join(tag_response) + possible_tag_keys = ("tag_string", "tag_string_general") + tag_response = [post[key].strip() for key in possible_tag_keys if key in post] + return " ".join(tag_response).lower().split() diff --git a/src/gelbooru_backend.py b/src/gelbooru_backend.py index 56727e6..6d64f04 100644 --- a/src/gelbooru_backend.py +++ b/src/gelbooru_backend.py @@ -29,15 +29,15 @@ def random_tag(*tags): def collect_tags(post): - return post["tags"].strip() + return post["tags"].strip().lower().split() - def is_banned(post, profile): tag_response = collect_tags(post) tag_banned = profile["banned_tags"] for tag in tag_banned: if tag in tag_response: + print(tag) return tag return None diff --git a/src/konachan_backend.py b/src/konachan_backend.py index 7f208da..d767053 100644 --- a/src/konachan_backend.py +++ b/src/konachan_backend.py @@ -29,12 +29,7 @@ def random_tag(*tags): def collect_tags(post): - tag_response = [] - for tag_type in "tag_string", "tag_string_general": - if tag_type in post: - tag_response.append(post[tag_type].strip()) - return " ".join(tag_response) - + return post["tags"].strip().lower().split() def is_banned(post, profile): @@ -46,7 +41,6 @@ def is_banned(post, profile): return None - def get_nsfw(post): return post["rating"] in ("q", "e") @@ -122,7 +116,6 @@ class downloader: def search(self, search_url): search_request = None - print(search_url) if self.username and self.password: search_request = requests.get(search_url, auth=(self.username, self.password)