From d3eed1e5b88de5ad8f05c1ef828823f60d9bb896 Mon Sep 17 00:00:00 2001 From: Solomon-Edwards <52939735+Solomon-Edwards@users.noreply.github.com> Date: Wed, 26 Jul 2023 23:56:22 +0800 Subject: [PATCH 1/6] Update aapi.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现在可以使用novel_follow()方法来获取关注的作家的新小说了 --- pixivpy3/aapi.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index 68b6e41..4a932e7 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -751,6 +751,27 @@ def novel_new( r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) return self.parse_result(r) + def novel_follow( + self, + req_auth: bool = True, + restrict:str= 'public', + offset:int|None = None + ) -> ParsedJson: + ''' + 返回已关注用户的新小说。最多30个项目。 + + restrict(int): 返回内容的限制。可以是 'all', 'public' or 'private'。public表示非R18且非R18G,private表示R18或R18G,all表示二者全部。 + + offset(int|None): 距离最新的小说的距离。为None时表示从最新的小说开始取得,为1时表示从第二新的小说开始取得,以此类推。不可以填0。 + ''' + url = "%s/v1/novel/follow" % self.hosts + params: dict[str, Any] = { + "restrict":restrict, + "offset":offset + } + r = self.no_auth_requests_call("GET", url, params=params,req_auth=req_auth) + return self.parse_result(r) + # 小说正文 def novel_text(self, novel_id: int | str, req_auth: bool = True) -> ParsedJson: url = "%s/v1/novel/text" % self.hosts From 69899fc800974e0156190057442015638db8d993 Mon Sep 17 00:00:00 2001 From: Solomon <52939735+Solomon-Edwards@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:06:15 +0800 Subject: [PATCH 2/6] =?UTF-8?q?Update=20aapi.py=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E4=BA=86=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了注释和空格 --- pixivpy3/aapi.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index 4a932e7..d793098 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -751,25 +751,14 @@ def novel_new( r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) return self.parse_result(r) + # 正在关注的用户的新小说 + # restrict: [public, private, all] def novel_follow( - self, - req_auth: bool = True, - restrict:str= 'public', - offset:int|None = None + self, restrict: _RESTRICT = 'public', offset: int | None = None, req_auth: bool = True ) -> ParsedJson: - ''' - 返回已关注用户的新小说。最多30个项目。 - - restrict(int): 返回内容的限制。可以是 'all', 'public' or 'private'。public表示非R18且非R18G,private表示R18或R18G,all表示二者全部。 - - offset(int|None): 距离最新的小说的距离。为None时表示从最新的小说开始取得,为1时表示从第二新的小说开始取得,以此类推。不可以填0。 - ''' url = "%s/v1/novel/follow" % self.hosts - params: dict[str, Any] = { - "restrict":restrict, - "offset":offset - } - r = self.no_auth_requests_call("GET", url, params=params,req_auth=req_auth) + params: dict[str, Any] = {"restrict": restrict, "offset": offset} + r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth) return self.parse_result(r) # 小说正文 From 83f526c7d65d013066c367f4b33571cff3cde244 Mon Sep 17 00:00:00 2001 From: Solomon <52939735+Solomon-Edwards@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:15:04 +0800 Subject: [PATCH 3/6] =?UTF-8?q?demo.py=20=E6=B7=BB=E5=8A=A0=E4=BA=86novel?= =?UTF-8?q?=5Ffollow()=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在appapi_novel()中添加了novel_follow()测试 --- demo.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/demo.py b/demo.py index efb9917..5644c4a 100644 --- a/demo.py +++ b/demo.py @@ -241,6 +241,14 @@ def appapi_novel(aapi): % (novel.title, novel.text_length, novel.series) ) + json_result = aapi.novel_follow() + print(json_result) + novel = json_result.novels[0] + print( + ">>> %s, text_length: %s, series: %s" + % (novel.title, novel.text_length, novel.series) + ) + # get next page next_qs = aapi.parse_qs(json_result.next_url) if next_qs is not None: From 9fe5dc059d18190c056e1df2e773a7dafb61971f Mon Sep 17 00:00:00 2001 From: Solomon <52939735+Solomon-Edwards@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:22:33 +0800 Subject: [PATCH 4/6] =?UTF-8?q?Update=20aapi.py=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E4=BA=86=E6=8D=A2=E8=A1=8C=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pixivpy3/aapi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index d793098..66e1d5f 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -754,7 +754,10 @@ def novel_new( # 正在关注的用户的新小说 # restrict: [public, private, all] def novel_follow( - self, restrict: _RESTRICT = 'public', offset: int | None = None, req_auth: bool = True + self, + restrict: _RESTRICT = "public", + offset: int | None = None, + req_auth: bool = True, ) -> ParsedJson: url = "%s/v1/novel/follow" % self.hosts params: dict[str, Any] = {"restrict": restrict, "offset": offset} From 6989d7b6f287fecb256dc07dc955fec04f55dba0 Mon Sep 17 00:00:00 2001 From: Solomon <52939735+Solomon-Edwards@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:40:44 +0800 Subject: [PATCH 5/6] =?UTF-8?q?Update=20demo.py=20=E6=8A=8Anovel=5Ffollow(?= =?UTF-8?q?)=E6=94=BE=E5=88=B0=E4=BA=86=E6=9C=80=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/demo.py b/demo.py index 5644c4a..fc431cb 100644 --- a/demo.py +++ b/demo.py @@ -241,14 +241,6 @@ def appapi_novel(aapi): % (novel.title, novel.text_length, novel.series) ) - json_result = aapi.novel_follow() - print(json_result) - novel = json_result.novels[0] - print( - ">>> %s, text_length: %s, series: %s" - % (novel.title, novel.text_length, novel.series) - ) - # get next page next_qs = aapi.parse_qs(json_result.next_url) if next_qs is not None: @@ -308,6 +300,13 @@ def appapi_novel(aapi): print(json_result) print(">>> {}, novel_text: {}".format(novel.title, json_result.novel_text)) + json_result = aapi.novel_follow() + print(json_result) + novel = json_result.novels[0] + print( + ">>> %s, text_length: %s, series: %s" + % (novel.title, novel.text_length, novel.series) + ) def main(): # app-api From 4cff5cb7db24230ec141f05d41fdf9b244888ea3 Mon Sep 17 00:00:00 2001 From: Solomon <52939735+Solomon-Edwards@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:54:15 +0800 Subject: [PATCH 6/6] Update demo.py --- demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/demo.py b/demo.py index fc431cb..e2ab0b3 100644 --- a/demo.py +++ b/demo.py @@ -308,6 +308,7 @@ def appapi_novel(aapi): % (novel.title, novel.text_length, novel.series) ) + def main(): # app-api aapi = AppPixivAPI(**_REQUESTS_KWARGS)