Updated tag system. Banned tags must now match exactly

This commit is contained in:
Anon 2022-10-15 16:07:10 -07:00
parent 0511d2fc54
commit dfbbbc7f22
3 changed files with 6 additions and 15 deletions

View File

@ -28,11 +28,9 @@ def random_tag(*tags):
def collect_tags(post): def collect_tags(post):
tag_response = [] possible_tag_keys = ("tag_string", "tag_string_general")
for tag_type in "tag_string", "tag_string_general": tag_response = [post[key].strip() for key in possible_tag_keys if key in post]
if tag_type in post: return " ".join(tag_response).lower().split()
tag_response.append(post[tag_type].strip())
return " ".join(tag_response)

View File

@ -29,8 +29,7 @@ def random_tag(*tags):
def collect_tags(post): def collect_tags(post):
return post["tags"].strip() return post["tags"].strip().lower().split()
def is_banned(post, profile): def is_banned(post, profile):
@ -38,6 +37,7 @@ def is_banned(post, profile):
tag_banned = profile["banned_tags"] tag_banned = profile["banned_tags"]
for tag in tag_banned: for tag in tag_banned:
if tag in tag_response: if tag in tag_response:
print(tag)
return tag return tag
return None return None

View File

@ -29,12 +29,7 @@ def random_tag(*tags):
def collect_tags(post): def collect_tags(post):
tag_response = [] return post["tags"].strip().lower().split()
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)
def is_banned(post, profile): def is_banned(post, profile):
@ -46,7 +41,6 @@ def is_banned(post, profile):
return None return None
def get_nsfw(post): def get_nsfw(post):
return post["rating"] in ("q", "e") return post["rating"] in ("q", "e")
@ -122,7 +116,6 @@ class downloader:
def search(self, search_url): def search(self, search_url):
search_request = None search_request = None
print(search_url)
if self.username and self.password: if self.username and self.password:
search_request = requests.get(search_url, search_request = requests.get(search_url,
auth=(self.username, self.password) auth=(self.username, self.password)