Skip to content

Commit

Permalink
[pixiv] add 'translated-tags' option (closes #1354)
Browse files Browse the repository at this point in the history
(a lot more straight forward than I thought ...)
  • Loading branch information
mikf committed Mar 5, 2021
1 parent 2e80610 commit 7440d1f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,16 @@ Description
Also download related artworks.


extractor.pixiv.translated-tags
-------------------------------
Type
``bool``
Default
``false``
Description
Provide translated ´`tags``.


extractor.pixiv.ugoira
----------------------
Type
Expand Down
1 change: 1 addition & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"pixiv":
{
"avatar": false,
"translated-tags": false,
"ugoira": true
},
"reactor":
Expand Down
5 changes: 3 additions & 2 deletions gallery_dl/extractor/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def __init__(self, match):
Extractor.__init__(self, match)
self.api = PixivAppAPI(self)
self.load_ugoira = self.config("ugoira", True)
self.translated_tags = self.config("translated-tags", False)

def items(self):
tkey = "translated_name" if self.translated_tags else "name"
ratings = {0: "General", 1: "R-18", 2: "R-18G"}
metadata = self.metadata()
yield Message.Version, 1

for work in self.works():
if not work["user"]["id"]:
Expand All @@ -45,7 +46,7 @@ def items(self):
del work["image_urls"]
del work["meta_pages"]
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["rating"] = ratings.get(work["x_restrict"])
work["suffix"] = ""
Expand Down

0 comments on commit 7440d1f

Please sign in to comment.