aapi中user_bookmark_tags_illust方法无法使用
xiyihan0 opened this issue · 3 comments
xiyihan0 commented
Pixivpy版本:3.7.2
代码如下:
_ACCESS_TOKEN = "..."
_REFRESH_TOKEN = "..."
from pixivpy3 import *
api = AppPixivAPI()
api.set_auth(access_token = _ACCESS_TOKEN,refresh_token=_REFRESH_TOKEN)
res_user_bookmarks_tags = api.user_bookmark_tags_illust(9373351)
print(res_user_bookmarks_tags)
输出结果如下:
{'error': {'user_message': '',
'message': '{"restrict":["restrict contains invalid value"]}',
'reason': '',
'user_message_details': {}}}
是否为api传入参数的问题?
upbit commented
Indeed, the user_bookmark_tags_illust
parameter does not support illust_id
. Instead, it accepts the offset
returned from the previous page (obtained from parse_qs
).
For more details, please refer to the parameter definitions in the API documentation:
# 用户收藏标签列表
def user_bookmark_tags_illust(
self,
restrict: _RESTRICT = "public",
offset: int | str | None = None,
req_auth: bool = True,
Just try: res_user_bookmarks_tags = api.user_bookmark_tags_illust()
xiyihan0 commented
感谢提醒!
事实上,刚才试了一下,这个方法也可以把user_id加上去:
# 用户收藏标签列表
def user_bookmark_tags_illust(
self,
user_id: int | str,
restrict: _RESTRICT = "public",
offset: int | str | None = None,
req_auth: bool = True,
) -> ParsedJson:
url = "%s/v1/user/bookmark-tags/illust" % self.hosts
params: dict[str, Any] = {
"user_id": user_id,
"restrict": restrict,
}
if offset:
params["offset"] = offset
r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth)
return self.parse_result(r)
结果:
{'name': '手マン', 'count': 3},
{'name': '明日方舟', 'count': 2},
{'name': '星极', 'count': 485},
{'name': '星源', 'count': 1},
{'name': '星空', 'count': 2},
{'name': '流れ星', 'count': 1},
{'name': '流星群', 'count': 1},
{'name': '見返り美人', 'count': 1},
{'name': '鏡に映る女の子', 'count': 1},
{'name': '鏡越し', 'count': 1},
{'name': '風景', 'count': 1},
{'name': '髪に手', 'count': 1}],
'next_url': None}
upbit commented
感谢提醒! 事实上,刚才试了一下,这个方法也可以把user_id加上去:
# 用户收藏标签列表 def user_bookmark_tags_illust( self, user_id: int | str, restrict: _RESTRICT = "public", offset: int | str | None = None, req_auth: bool = True, ) -> ParsedJson: url = "%s/v1/user/bookmark-tags/illust" % self.hosts params: dict[str, Any] = { "user_id": user_id, "restrict": restrict, } if offset: params["offset"] = offset r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) return self.parse_result(r)
如果确认新版API有 user_id
这个参数,欢迎提交MR进行优化(记得同步修改demo里的案例)