[booru] prevent crash when no tags are present (#259)

This commit is contained in:
Mike Fährmann
2019-05-17 14:41:24 +02:00
parent ca3bad1779
commit a4ba34c835

View File

@@ -94,7 +94,7 @@ class BooruExtractor(SharedConfigMixin, Extractor):
tags = collections.defaultdict(list) tags = collections.defaultdict(list)
tags_html = text.extract(page, '<ul id="tag-', '</ul>')[0] tags_html = text.extract(page, '<ul id="tag-', '</ul>')[0]
pattern = re.compile(r"tag-type-([^\"' ]+).*?[?;]tags=([^\"']+)", re.S) pattern = re.compile(r"tag-type-([^\"' ]+).*?[?;]tags=([^\"']+)", re.S)
for tag_type, tag_name in pattern.findall(tags_html): for tag_type, tag_name in pattern.findall(tags_html or ""):
tags[tag_type].append(text.unquote(tag_name)) tags[tag_type].append(text.unquote(tag_name))
for key, value in tags.items(): for key, value in tags.items():
image["tags_" + key] = " ".join(value) image["tags_" + key] = " ".join(value)