Better error handling to skip non-standard ss_tag_frequency content

This commit is contained in:
Brendan Hoar 2024-04-26 06:44:41 -04:00 committed by GitHub
parent ddb28b33a3
commit 3902aa222b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,10 +21,12 @@ re_comma = re.compile(r" *, *")
def build_tags(metadata):
tags = {}
for _, tags_dict in metadata.get("ss_tag_frequency", {}).items():
for tag, tag_count in tags_dict.items():
tag = tag.strip()
tags[tag] = tags.get(tag, 0) + int(tag_count)
ss_tag_frequency = metadata.get("ss_tag_frequency", {})
if ss_tag_frequency is not None and hasattr(ss_tag_frequency, 'items'):
for _, tags_dict in ss_tag_frequency.items():
for tag, tag_count in tags_dict.items():
tag = tag.strip()
tags[tag] = tags.get(tag, 0) + int(tag_count)
if tags and is_non_comma_tagset(tags):
new_tags = {}