1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[exhentai] implement 'tags' option (#2117)

allow splitting tags into categories,
e.g. 'tags_parody', 'tags_group', etc.
This commit is contained in:
Mike Fährmann 2024-11-15 21:47:13 +01:00
parent 1264fc518b
commit 0d1469f229
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 13 additions and 1 deletions

View File

@ -11,6 +11,7 @@
from .common import Extractor, Message
from .. import text, util, exception
from ..cache import cache
import collections
import itertools
import math
@ -227,6 +228,13 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
if self.config("metadata", False):
data.update(self.metadata_from_api())
data["date"] = text.parse_timestamp(data["posted"])
if self.config("tags", False):
tags = collections.defaultdict(list)
for tag in data["tags"]:
type, _, value = tag.partition(":")
tags[type].append(value)
for type, values in tags.items():
data["tags_" + type] = values
return data
def metadata_from_page(self, page):

View File

@ -13,7 +13,7 @@ __tests__ = (
"#url" : "https://exhentai.org/g/1200119/d55c44d3d0/",
"#category": ("", "exhentai", "gallery"),
"#class" : exhentai.ExhentaiGalleryExtractor,
"#options" : {"original": False},
"#options" : {"original": False, "tags": True},
"#sha1_content": [
"2c68cff8a7ca540a78c36fdbf5fbae0260484f87",
"e9891a4c017ed0bb734cd1efba5cd03f594d31ff",
@ -40,6 +40,10 @@ __tests__ = (
"group:seventh lowlife",
"other:sample",
],
"tags_parody" : ["komi-san wa komyushou desu."],
"tags_character": ["shouko komi"],
"tags_group" : ["seventh lowlife"],
"tags_other" : ["sample"],
"thumb" : "https://s.exhentai.org/t/ce/0a/ce0a5bcb583229a9b07c0f83bcb1630ab1350640-624622-736-1036-jpg_250.jpg",
"title" : "C93 [Seventh_Lowlife] Komi-san ha Tokidoki Daitan desu (Komi-san wa Komyushou desu) [Sample]",
"title_jpn" : "(C93) [Comiketjack (わ!)] 古見さんは、時々大胆です。 (古見さんは、コミュ症です。) [見本]",