From b58af14bdb64e9e11cb902a260f0e77858360fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 11 Dec 2024 11:52:42 +0100 Subject: [PATCH] [itaku] update - simplify code - update docs/supportedsites - update test results --- docs/supportedsites.md | 2 +- gallery_dl/extractor/itaku.py | 28 ++++++++++++---------------- test/results/itaku.py | 7 ++++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index ecbf93f1..aa9bce2d 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -478,7 +478,7 @@ Consider all listed sites to potentially be NSFW. Itaku https://itaku.ee/ - Galleries, individual Images + Galleries, individual Images, Search Results diff --git a/gallery_dl/extractor/itaku.py b/gallery_dl/extractor/itaku.py index b5a8f356..7f941bb8 100644 --- a/gallery_dl/extractor/itaku.py +++ b/gallery_dl/extractor/itaku.py @@ -102,15 +102,15 @@ class ItakuAPI(): required_tags = [] negative_tags = [] optional_tags = [] - tags = [] - tags_param = params.get("tags") - if isinstance(tags_param, str): - tags = [tags_param] - elif isinstance(tags_param, list): - tags = tags_param + + tags = params.pop("tags", None) + if not tags: + tags = () + elif isinstance(tags, str): + tags = (tags,) for tag in tags: - if len(tag) == 0: + if not tag: pass elif tag[0] == "-": negative_tags.append(tag[1:]) @@ -119,22 +119,18 @@ class ItakuAPI(): else: required_tags.append(tag) - # Every param is simply passed through to the api, except "tags" - if "tags" in params: - del params["tags"] - api_params = { "required_tags": required_tags, "negative_tags": negative_tags, "optional_tags": optional_tags, - "page": 1, - "page_size": 30, + "date_range": "", "maturity_rating": ("SFW", "Questionable", "NSFW"), - "ordering": "-date_added", + "ordering" : "-date_added", + "page" : "1", + "page_size" : "30", "visibility": ("PUBLIC", "PROFILE_ONLY"), - **params } - + api_params.update(params) return self._pagination(endpoint, api_params, self.image) def galleries_images(self, username, section=None): diff --git a/test/results/itaku.py b/test/results/itaku.py index b76a4cc8..5a95bd84 100644 --- a/test/results/itaku.py +++ b/test/results/itaku.py @@ -83,7 +83,8 @@ __tests__ = ( "#comment" : "simple search", "#category": ("", "itaku", "search"), "#class" : itaku.ItakuSearchExtractor, - "#count" : "> 1", + "#range" : "1-10", + "#count" : 10, }, { @@ -91,7 +92,7 @@ __tests__ = ( "#comment" : "search for videos", "#category": ("", "itaku", "search"), "#class" : itaku.ItakuSearchExtractor, - "#count" : 30, + "#count" : range(5, 50), }, { @@ -99,6 +100,6 @@ __tests__ = ( "#comment" : "search with postive, negative, and optional tags", "#category": ("", "itaku", "search"), "#class" : itaku.ItakuSearchExtractor, - "#count" : 0 + "#count" : 0, }, )