[pixiv] implement 'max-posts' option (#1558)

* implement max-rank for pixiv

* rename to max-posts and make more generic
This commit is contained in:
thatfuckingbird
2021-05-24 17:49:46 +02:00
committed by GitHub
parent 8a909e478d
commit e6811c7450
2 changed files with 16 additions and 1 deletions

View File

@@ -1419,6 +1419,17 @@ Description
.. __: https://github.com/mikf/gallery-dl/blob/v1.12.3/docs/gallery-dl-example.conf#L9-L14 .. __: https://github.com/mikf/gallery-dl/blob/v1.12.3/docs/gallery-dl-example.conf#L9-L14
extractor.pixiv.max-posts
-------------------------
Type
``integer``
Default
``0``
Description
When downloading galleries, this sets the maximum number of posts to get.
A value of ``0`` means no limit.
extractor.plurk.comments extractor.plurk.comments
------------------------ ------------------------
Type Type

View File

@@ -29,6 +29,7 @@ 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.max_posts = self.config("max-posts", 0)
def items(self): def items(self):
tags = self.config("tags", "japanese") tags = self.config("tags", "japanese")
@@ -46,7 +47,10 @@ class PixivExtractor(Extractor):
ratings = {0: "General", 1: "R-18", 2: "R-18G"} ratings = {0: "General", 1: "R-18", 2: "R-18G"}
metadata = self.metadata() 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"]: if not work["user"]["id"]:
continue continue