diff options
Diffstat (limited to 'gallery_dl/extractor/pixiv.py')
| -rw-r--r-- | gallery_dl/extractor/pixiv.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index 8bfae06..8076fff 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -29,14 +29,28 @@ class PixivExtractor(Extractor): Extractor.__init__(self, match) self.api = PixivAppAPI(self) self.load_ugoira = self.config("ugoira", True) - self.translated_tags = self.config("translated-tags", False) + self.max_posts = self.config("max-posts", 0) def items(self): - tkey = "translated_name" if self.translated_tags else "name" + tags = self.config("tags", "japanese") + if tags == "original": + transform_tags = None + elif tags == "translated": + def transform_tags(work): + work["tags"] = list(set( + tag["translated_name"] or tag["name"] + for tag in work["tags"])) + else: + def transform_tags(work): + work["tags"] = [tag["name"] for tag in work["tags"]] + ratings = {0: "General", 1: "R-18", 2: "R-18G"} metadata = self.metadata() - for work in self.works(): + works = self.works() + if self.max_posts: + works = itertools.islice(works, self.max_posts) + for work in works: if not work["user"]["id"]: continue @@ -45,12 +59,10 @@ class PixivExtractor(Extractor): del work["meta_single_page"] del work["image_urls"] del work["meta_pages"] + + if transform_tags: + transform_tags(work) work["num"] = 0 - if self.translated_tags: - work["untranslated_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"] = "" @@ -66,6 +78,7 @@ class PixivExtractor(Extractor): url = ugoira["zip_urls"]["medium"].replace( "_ugoira600x600", "_ugoira1920x1080") work["frames"] = ugoira["frames"] + work["_http_adjust_extension"] = False yield Message.Url, url, text.nameext_from_url(url, work) elif work["page_count"] == 1: @@ -115,7 +128,8 @@ class PixivUserExtractor(PixivExtractor): }), # deleted account ("http://www.pixiv.net/member_illust.php?id=173531", { - "count": 0, + "options": (("metadata", True),), + "exception": exception.NotFoundError, }), ("https://www.pixiv.net/en/users/173530"), ("https://www.pixiv.net/en/users/173530/manga"), @@ -138,6 +152,11 @@ class PixivUserExtractor(PixivExtractor): self.user_id = u1 or u2 or u3 self.tag = t1 or t2 + def metadata(self): + if self.config("metadata"): + return {"user": self.api.user_detail(self.user_id)} + return {} + def works(self): works = self.api.user_illusts(self.user_id) |
