From 03a9ce9832c12c03ed5221f04a470d9e9d6d9b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 15 Mar 2024 23:04:10 +0100 Subject: [PATCH] [kemonoparty] add 'order-revisions' option (#5334) --- docs/configuration.rst | 16 ++++++++++++++++ gallery_dl/extractor/kemonoparty.py | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 65a076ebc62..295780193a7 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2346,6 +2346,22 @@ Description Note: This requires 1 additional HTTP request per post. +extractor.kemonoparty.order-revisions +------------------------------------- +Type + ``string`` +Default + ``"desc"`` +Description + Controls the order in which + `revisions `__ + are returned. + + * ``"asc"``: Ascending order (oldest first) + * ``"desc"``: Descending order (newest first) + * ``"reverse"``: Same as ``"asc"`` + + extractor.khinsider.format -------------------------- Type diff --git a/gallery_dl/extractor/kemonoparty.py b/gallery_dl/extractor/kemonoparty.py index 13897b49a89..de2a9b6cc9a 100644 --- a/gallery_dl/extractor/kemonoparty.py +++ b/gallery_dl/extractor/kemonoparty.py @@ -40,6 +40,8 @@ def __init__(self, match): def _init(self): self.revisions = self.config("revisions") if self.revisions: + order = self.config("order-revisions") + self.revisions_reverse = order[0] in ("r", "a") if order else False self.revisions_unique = (self.revisions == "unique") self._prepare_ddosguard_cookies() self._find_inline = re.compile( @@ -254,6 +256,9 @@ def _revisions_post(self, post, url): rev["revision_count"] = cnt idx -= 1 + if self.revisions_reverse: + revs.reverse() + return revs def _revisions_all(self, url): @@ -266,6 +271,9 @@ def _revisions_all(self, url): rev["revision_count"] = cnt idx -= 1 + if self.revisions_reverse: + revs.reverse() + return revs def _revision_hash(self, revision):