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):
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()

View File

@ -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

View File

@ -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)