Skip to content

Commit

Permalink
add user_bookmarks_novel (#284)
Browse files Browse the repository at this point in the history
* add user_bookmarks_novel

* fix comments
  • Loading branch information
vNKB7 authored Oct 2, 2023
1 parent b4f5a7f commit 8975a07
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class AppPixivAPI(BasePixivAPI):
# tag: 从 user_bookmark_tags_illust 获取的收藏标签
def user_bookmarks_illust(user_id, restrict="public"):

# 用户收藏作品列表中的小说
def user_bookmarks_novel(user_id, restrict="public"):

def user_related(seed_user_id):

# 关注用户的新作
Expand Down Expand Up @@ -362,6 +365,12 @@ print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

# 用户收藏列表中的小说
json_result = aapi.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(">>> {}, text_length: {}, series: {}".format(novel.title, novel.text_length, novel.series))

# 2016-07-15 日的过去一周排行
json_result = aapi.illust_ranking('week', date='2016-07-15')
print(json_result)
Expand Down
5 changes: 5 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def appapi_users(aapi):
illust = json_result.illusts[0]
print(">>> {}, origin url: {}".format(illust.title, illust.image_urls["large"]))

json_result = aapi.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(">>> {}, text_length: {}, series: {}".format(novel.title, novel.text_length, novel.series))

json_result = aapi.user_following(7314824)
print(json_result)
user_preview = json_result.user_previews[0]
Expand Down
23 changes: 23 additions & 0 deletions pixivpy3/aapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ def user_bookmarks_illust(
r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth)
return self.parse_result(r)

# 用户收藏小说列表
def user_bookmarks_novel(
self,
user_id: int | str,
restrict: _RESTRICT = "public",
filter: _FILTER = "for_ios",
max_bookmark_id: int | str | None = None,
tag: str | None = None,
req_auth: bool = True,
) -> ParsedJson:
url = "%s/v1/user/bookmarks/novel" % self.hosts
params = {
"user_id": user_id,
"restrict": restrict,
"filter": filter,
}
if max_bookmark_id:
params["max_bookmark_id"] = max_bookmark_id
if tag:
params["tag"] = tag
r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth)
return self.parse_result(r)

def user_related(
self,
seed_user_id: int | str,
Expand Down

0 comments on commit 8975a07

Please sign in to comment.