Skip to content

Commit

Permalink
[kemonoparty] add 'order-revisions' option (mikf#5334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 15, 2024
1 parent 1418c0c commit 03a9ce9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <extractor.kemonoparty.revisions_>`__
are returned.

* ``"asc"``: Ascending order (oldest first)
* ``"desc"``: Descending order (newest first)
* ``"reverse"``: Same as ``"asc"``


extractor.khinsider.format
--------------------------
Type
Expand Down
8 changes: 8 additions & 0 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 03a9ce9

Please sign in to comment.