From a082f1dd32bbb2897e597c1f967e619886422ce6 Mon Sep 17 00:00:00 2001 From: Hao Zhou Date: Sun, 3 Mar 2024 17:01:47 +0800 Subject: [PATCH] fix2 --- README.md | 2 +- pixivpy3/aapi.py | 2 +- pixivpy3/api.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1291cee..f9b4406 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ _Pixiv API for Python (with Auth supported)_ -- [2024/03/03] _v3.7.5_ Fix `novel_text()` BUG, add `webview_novel()`, see +- [2024/03/03] _v3.7.5_ Fix `novel_text()` BUG, add `webview_novel()`, see [#337](https://github.com/upbit/pixivpy/issues/337) (thanks [@xiyihan](https://github.com/xiyihan0)) - [2023/09/18] _v3.7.3_ Add `novel_follow()`, fix ByPassSniApi() host BUG, see diff --git a/pixivpy3/aapi.py b/pixivpy3/aapi.py index c82a4a8..a2d4d6f 100644 --- a/pixivpy3/aapi.py +++ b/pixivpy3/aapi.py @@ -815,7 +815,7 @@ def webview_novel(self, novel_id: int | str, raw: bool = False, req_auth: bool = return r.text try: # extract JSON content - json_str = re.search(r"novel:\s({.+}),\s+isOwnWork", r.text).groups()[0].encode() # type: ignore + json_str = re.search(r"novel:\s({.+}),\s+isOwnWork", r.text).groups()[0].encode() # type: ignore return self.parse_json(json_str) except Exception as e: raise PixivError("Extract novel content error: %s" % e, header=r.headers, body=r.text) diff --git a/pixivpy3/api.py b/pixivpy3/api.py index a55cbe5..7762776 100644 --- a/pixivpy3/api.py +++ b/pixivpy3/api.py @@ -5,7 +5,7 @@ import os import shutil from datetime import datetime -from typing import IO, Any, Union +from typing import IO, Any import cloudscraper # type: ignore[import] from requests.structures import CaseInsensitiveDict @@ -44,7 +44,7 @@ def set_accept_language(self, language: str) -> None: self.additional_headers["Accept-Language"] = language @classmethod - def parse_json(cls, json_str: Union[str, bytes, Any]) -> ParsedJson: + def parse_json(cls, json_str: str | bytes) -> ParsedJson: """parse str into JsonDict""" return json.loads(json_str, object_hook=JsonDict)