From b06c06ff9138d589f7c9e3ff4242723587418c41 Mon Sep 17 00:00:00 2001 From: Igor Krohin <31508183+nautics889@users.noreply.github.com> Date: Sat, 18 Mar 2023 04:45:46 +0200 Subject: [PATCH] Fix: add passing `viewed` parameter (#247) (#262) Updated methods `illust_related()`, `illust_recommended()` in `AppPixivAPI` class. Both of them have had `viewed` parameter in their signatures but the parameter was unused. --- pixivpy3/aapi.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index 1ff263f..f477518 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -262,7 +262,7 @@ def illust_related( filter: _FILTER = "for_ios", seed_illust_ids: int | str | list[str] | None = None, offset: int | str | None = None, - viewed: list[str] | None = None, + viewed: str | list[str] | None = None, req_auth: bool = True, ) -> ParsedJson: url = "%s/v2/illust/related" % self.hosts @@ -275,6 +275,10 @@ def illust_related( params["seed_illust_ids[]"] = [seed_illust_ids] elif isinstance(seed_illust_ids, list): params["seed_illust_ids[]"] = seed_illust_ids + if isinstance(viewed, str): + params["viewed[]"] = [viewed] + elif isinstance(viewed, list): + params["viewed[]"] = viewed r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) return self.parse_result(r) @@ -291,7 +295,7 @@ def illust_recommended( include_ranking_illusts: str | bool | None = None, bookmark_illust_ids: str | list[int | str] | None = None, include_privacy_policy: str | list[int | str] | None = None, - viewed: list[str] | None = None, + viewed: str | list[str] | None = None, req_auth: bool = True, ) -> ParsedJson: if req_auth: @@ -315,6 +319,10 @@ def illust_recommended( params["include_ranking_illusts"] = self.format_bool( include_ranking_illusts ) + if isinstance(viewed, str): + params["viewed[]"] = [viewed] + elif isinstance(viewed, list): + params["viewed[]"] = viewed if not req_auth: if isinstance(bookmark_illust_ids, str):