From d0ad6d0e67973e7adebea6215609456889da6170 Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:15:36 +0800 Subject: [PATCH] [e621] implement manual pagination mode --- docs/configuration.rst | 14 ++++++++++++++ gallery_dl/extractor/danbooru.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 996f33f4..8c827f25 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1004,6 +1004,20 @@ Description Note: This requires 1 additional HTTP request for each post. +extractor.danbooru.pagination +----------------------------- +Type + ``string`` +Default + ``"length"`` +Description + Controls when to stop paginating over API results. + + * ``"length"``: Stop when the length of a batch of results is less than + the page limit. + * ``"manual"``: Only stop when a batch of results is empty. + + extractor.danbooru.ugoira ------------------------- Type diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index 5a44780e..f352c0c2 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -41,6 +41,7 @@ class DanbooruExtractor(BaseExtractor): self.ugoira = self.config("ugoira", False) self.external = self.config("external", False) self.extended_metadata = self.config("metadata", False) + self.strategy = self.config("pagination", "length") username, api_key = self._get_auth_info() if username: @@ -126,7 +127,7 @@ class DanbooruExtractor(BaseExtractor): posts = posts["posts"] yield from posts - if len(posts) < self.per_page: + if self.strategy == "length" and len(posts) < self.per_page: return if pagenum: