mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[zerochan] implement 'tags' option (#5874)
allow splitting tags into separate lists by category
This commit is contained in:
parent
1aadc29c5b
commit
5207a0c2e0
@ -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…
Reference in New Issue
Block a user