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:
parent
1264fc518b
commit
0d1469f229
@ -11,6 +11,7 @@
|
|||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, util, exception
|
from .. import text, util, exception
|
||||||
from ..cache import cache
|
from ..cache import cache
|
||||||
|
import collections
|
||||||
import itertools
|
import itertools
|
||||||
import math
|
import math
|
||||||
|
|
||||||
@ -227,6 +228,13 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
|||||||
if self.config("metadata", False):
|
if self.config("metadata", False):
|
||||||
data.update(self.metadata_from_api())
|
data.update(self.metadata_from_api())
|
||||||
data["date"] = text.parse_timestamp(data["posted"])
|
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
|
return data
|
||||||
|
|
||||||
def metadata_from_page(self, page):
|
def metadata_from_page(self, page):
|
||||||
|
@ -13,7 +13,7 @@ __tests__ = (
|
|||||||
"#url" : "https://exhentai.org/g/1200119/d55c44d3d0/",
|
"#url" : "https://exhentai.org/g/1200119/d55c44d3d0/",
|
||||||
"#category": ("", "exhentai", "gallery"),
|
"#category": ("", "exhentai", "gallery"),
|
||||||
"#class" : exhentai.ExhentaiGalleryExtractor,
|
"#class" : exhentai.ExhentaiGalleryExtractor,
|
||||||
"#options" : {"original": False},
|
"#options" : {"original": False, "tags": True},
|
||||||
"#sha1_content": [
|
"#sha1_content": [
|
||||||
"2c68cff8a7ca540a78c36fdbf5fbae0260484f87",
|
"2c68cff8a7ca540a78c36fdbf5fbae0260484f87",
|
||||||
"e9891a4c017ed0bb734cd1efba5cd03f594d31ff",
|
"e9891a4c017ed0bb734cd1efba5cd03f594d31ff",
|
||||||
@ -40,6 +40,10 @@ __tests__ = (
|
|||||||
"group:seventh lowlife",
|
"group:seventh lowlife",
|
||||||
"other:sample",
|
"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",
|
"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" : "C93 [Seventh_Lowlife] Komi-san ha Tokidoki Daitan desu (Komi-san wa Komyushou desu) [Sample]",
|
||||||
"title_jpn" : "(C93) [Comiketjack (わ!)] 古見さんは、時々大胆です。 (古見さんは、コミュ症です。) [見本]",
|
"title_jpn" : "(C93) [Comiketjack (わ!)] 古見さんは、時々大胆です。 (古見さんは、コミュ症です。) [見本]",
|
||||||
|
Loading…
Reference in New Issue
Block a user