diff --git a/docs/configuration.rst b/docs/configuration.rst index cfe61152..a41aa328 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3707,6 +3707,24 @@ Note It is possible to use ``"all"`` instead of listing all values separately. +extractor.itaku.order +--------------------- +Type + ``string`` +Default + ``"desc"`` +Description + Controls the order in which + images/posts/users are returned. + + ``"asc"`` | ``"reverse"`` + Ascending order (oldest first) + ``"desc"`` + Descending order (newest first) + any other ``string`` + Custom result order + + extractor.itaku.videos ---------------------- Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 5090fe11..901b9be8 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -474,6 +474,7 @@ { "sleep-request": "0.5-1.5", "include": "gallery", + "order" : "desc", "videos" : true }, "iwara": diff --git a/gallery_dl/extractor/itaku.py b/gallery_dl/extractor/itaku.py index 703a46d4..10579c1c 100644 --- a/gallery_dl/extractor/itaku.py +++ b/gallery_dl/extractor/itaku.py @@ -182,11 +182,11 @@ class ItakuUserExtractor(Dispatch, ItakuExtractor): def items(self): base = f"{self.root}/profile/{self.groups[0]}/" return self._dispatch_extractors(( - (ItakuGalleryExtractor , base + "gallery"), - (ItakuPostsExtractor , base + "posts"), - (ItakuFollowersExtractor, base + "followers"), - (ItakuFollowingExtractor, base + "following"), - (ItakuStarsExtractor , base + "stars"), + (ItakuGalleryExtractor , f"{base}gallery"), + (ItakuPostsExtractor , f"{base}posts"), + (ItakuFollowersExtractor, f"{base}followers"), + (ItakuFollowingExtractor, f"{base}following"), + (ItakuStarsExtractor , f"{base}stars"), ), ("gallery",)) @@ -246,7 +246,7 @@ class ItakuAPI(): def __init__(self, extractor): self.extractor = extractor - self.root = extractor.root + "/api" + self.root = f"{extractor.root}/api" self.headers = { "Accept": "application/json, text/plain, */*", } @@ -257,7 +257,7 @@ class ItakuAPI(): "cursor" : None, "date_range": "", "maturity_rating": ("SFW", "Questionable", "NSFW"), - "ordering" : "-date_added", + "ordering" : self._order(), "page" : "1", "page_size" : "30", "visibility": ("PUBLIC", "PROFILE_ONLY"), @@ -271,7 +271,7 @@ class ItakuAPI(): "cursor" : None, "date_range": "", "maturity_rating": ("SFW", "Questionable", "NSFW"), - "ordering" : "-date_added", + "ordering" : self._order(), "page" : "1", "page_size" : "30", **params, @@ -282,7 +282,7 @@ class ItakuAPI(): endpoint = "/user_profiles/" params = { "cursor" : None, - "ordering" : "-date_added", + "ordering" : self._order(), "page" : "1", "page_size": "50", "sfw_only" : "false", @@ -309,7 +309,7 @@ class ItakuAPI(): def _call(self, endpoint, params=None): if not endpoint.startswith("http"): - endpoint = self.root + endpoint + endpoint = f"{self.root}{endpoint}" return self.extractor.request_json( endpoint, params=params, headers=self.headers) @@ -328,3 +328,11 @@ class ItakuAPI(): return data = self._call(url_next) + + def _order(self): + if order := self.extractor.config("order"): + if order in {"a", "asc", "r", "reverse"}: + return "date_added" + if order not in {"d", "desc"}: + return order + return "-date_added" diff --git a/test/results/itaku.py b/test/results/itaku.py index 28357d59..48dfe61e 100644 --- a/test/results/itaku.py +++ b/test/results/itaku.py @@ -49,6 +49,19 @@ __tests__ = ( "sections" : ["Fanart/Pokemon"], }, +{ + "#url" : "https://itaku.ee/profile/piku/gallery/7391", + "#comment" : "'order' option", + "#class" : itaku.ItakuGalleryExtractor, + "#options" : {"order": "reverse"}, + "#results" : ( + "https://itaku.ee/api/media/gallery_imgs/bea_alpha_N0YGfeT.png", + "https://itaku.ee/api/media/gallery_imgs/misty-psyduck_IWbYdwT.png", + ), + + "sections" : ["Fanart/Pokemon"], +}, + { "#url" : "https://itaku.ee/profile/piku/posts", "#class" : itaku.ItakuPostsExtractor,