diff --git a/demo.py b/demo.py index e78f6b1..d014e73 100644 --- a/demo.py +++ b/demo.py @@ -158,6 +158,11 @@ def appapi_search(aapi): novel = json_result.novels[0] print(">>> {}, origin url: {}".format(novel.title, novel.image_urls["large"])) + json_result = aapi.search_illust("AI生成", search_target="exact_match_for_tags", search_ai_type=0) + # 关闭AI搜索选项后,将过滤掉所有illust_ai_type=2的插画,而illust_ai_type=1 or 0 的插画将被保留 + # 但是,加入了"AI生成"的tag却没有在作品提交时打开“AI生成”的开关的作品不会被筛选出结果列表 + print(json_result["illusts"][0]) + def appapi_user_search(aapi): json_result = aapi.illust_ranking("day_male") diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index c8fd699..1492385 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -458,6 +458,7 @@ def trending_tags_illust(self, filter: _FILTER = "for_ios", req_auth: bool = Tru # title_and_caption - 标题说明文 # sort: [date_desc, date_asc, popular_desc] - popular_desc为会员的热门排序 # duration: [within_last_day, within_last_week, within_last_month] + # search_ai_type: 0|1 (0: 过滤AI生成作品, 1: 显示AI生成作品) # start_date, end_date: '2020-07-01' def search_illust( self, @@ -468,6 +469,7 @@ def search_illust( start_date: str | None = None, end_date: str | None = None, filter: _FILTER = "for_ios", + search_ai_type: Literal[0, 1] | None = None, offset: int | str | None = None, req_auth: bool = True, ) -> ParsedJson: @@ -484,6 +486,8 @@ def search_illust( params["end_date"] = end_date if duration: params["duration"] = duration + if search_ai_type: + params["search_ai_type"] = search_ai_type if offset: params["offset"] = offset r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) @@ -496,6 +500,7 @@ def search_illust( # text - 正文 # keyword - 关键词 # sort: [date_desc, date_asc] + # search_ai_type: 0|1 (0: 过滤AI生成作品, 1: 显示AI生成作品) # start_date/end_date: 2020-06-01 def search_novel( self, @@ -507,6 +512,7 @@ def search_novel( start_date: str | None = None, end_date: str | None = None, filter: str | None = None, + search_ai_type: Literal[0, 1] | None = None, offset: int | str | None = None, req_auth: bool = True, ) -> ParsedJson: @@ -523,6 +529,8 @@ def search_novel( params["start_date"] = start_date if end_date: params["end_date"] = end_date + if search_ai_type: + params["search_ai_type"] = search_ai_type if offset: params["offset"] = offset r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) @@ -608,6 +616,13 @@ def user_follow_delete(self, user_id: int | str, req_auth: bool = True) -> Parse r = self.no_auth_requests_call("POST", url, data=data, req_auth=req_auth) return self.parse_result(r) + # 设置用户选项中是否展现AI生成作品 + def user_edit_ai_show_settings(self, setting: _BOOL, req_auth: bool = True) -> ParsedJson: + url = "%s/v1/user/ai-show-settings/edit" % self.hosts + data = {"show_ai": setting} + r = self.no_auth_requests_call("POST", url, data=data, req_auth=req_auth) + return self.parse_result(r) + # 用户收藏标签列表 def user_bookmark_tags_illust( self,