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

allow splitting tags into separate lists by category
pull/5887/head
Mike Fährmann 2 months ago
parent 1aadc29c5b
commit 5207a0c2e0
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

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

@ -120,6 +120,7 @@ __tests__ = (
"#category": ("booru", "zerochan", "image"),
"#class" : zerochan.ZerochanImageExtractor,
"#urls" : "https://static.zerochan.net/DRAGON.BALL.full.4233756.jpg",
"#options" : {"tags": True},
"author" : "Raydash",
"date" : "dt:2024-07-23 00:10:51",
@ -149,9 +150,31 @@ __tests__ = (
"Source:Fanart from X (Twitter)",
"Source:X (Twitter)",
],
"tags_character": [
"Piccolo",
"Son Gohan",
],
"tags_mangaka" : [
"Raydash",
],
"tags_series" : [
"DRAGON BALL",
"DRAGON BALL Z",
],
"tags_source" : [
"Fanart",
"Fanart from X (Twitter)",
"X (Twitter)",
],
"tags_theme" : [
"Duo",
"Green Skin",
"Male",
"Male Focus",
"Two Males",
],
"uploader" : "menotbug",
"width" : 750,
},
)

Loading…
Cancel
Save