[zerochan] implement 'tags' option (#5874)

allow splitting tags into separate lists by category
This commit is contained in:
Mike Fährmann
2024-07-23 09:50:06 +02:00
parent 1aadc29c5b
commit 5207a0c2e0
2 changed files with 33 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
from .booru import BooruExtractor
from ..cache import cache
from .. import text, util, exception
import collections
BASE_PATTERN = r"(?:https?://)?(?:www\.)?zerochan\.net"
@@ -109,6 +110,14 @@ class ZerochanExtractor(BooruExtractor):
return data
def _tags(self, post, page):
tags = collections.defaultdict(list)
for tag in post["tags"]:
category, _, name = tag.partition(":")
tags[category].append(name)
for key, value in tags.items():
post["tags_" + key.lower()] = value
class ZerochanTagExtractor(ZerochanExtractor):
subcategory = "tag"