[pixiv] add 'translated-tags' option (closes #1354)

(a lot more straight forward than I thought ...)
This commit is contained in:
Mike Fährmann
2021-03-05 17:18:51 +01:00
parent 2e8061091a
commit 7440d1f112
3 changed files with 14 additions and 2 deletions

View File

@@ -1298,6 +1298,16 @@ Description
Also download related artworks. Also download related artworks.
extractor.pixiv.translated-tags
-------------------------------
Type
``bool``
Default
``false``
Description
Provide translated ´`tags``.
extractor.pixiv.ugoira extractor.pixiv.ugoira
---------------------- ----------------------
Type Type

View File

@@ -183,6 +183,7 @@
"pixiv": "pixiv":
{ {
"avatar": false, "avatar": false,
"translated-tags": false,
"ugoira": true "ugoira": true
}, },
"reactor": "reactor":

View File

@@ -29,11 +29,12 @@ class PixivExtractor(Extractor):
Extractor.__init__(self, match) Extractor.__init__(self, match)
self.api = PixivAppAPI(self) self.api = PixivAppAPI(self)
self.load_ugoira = self.config("ugoira", True) self.load_ugoira = self.config("ugoira", True)
self.translated_tags = self.config("translated-tags", False)
def items(self): def items(self):
tkey = "translated_name" if self.translated_tags else "name"
ratings = {0: "General", 1: "R-18", 2: "R-18G"} ratings = {0: "General", 1: "R-18", 2: "R-18G"}
metadata = self.metadata() metadata = self.metadata()
yield Message.Version, 1
for work in self.works(): for work in self.works():
if not work["user"]["id"]: if not work["user"]["id"]:
@@ -45,7 +46,7 @@ class PixivExtractor(Extractor):
del work["image_urls"] del work["image_urls"]
del work["meta_pages"] del work["meta_pages"]
work["num"] = 0 work["num"] = 0
work["tags"] = [tag["name"] for tag in work["tags"]] work["tags"] = [tag[tkey] or tag["name"] for tag in work["tags"]]
work["date"] = text.parse_datetime(work["create_date"]) work["date"] = text.parse_datetime(work["create_date"])
work["rating"] = ratings.get(work["x_restrict"]) work["rating"] = ratings.get(work["x_restrict"])
work["suffix"] = "" work["suffix"] = ""