upbit / pixivpy

Pixiv API for Python
https://pypi.org/project/PixivPy3/#files
The Unlicense
1.78k stars 148 forks source link

fix: `datetime.utcnow()` deprecation warning #348

Open nautics889 opened 6 months ago

nautics889 commented 6 months ago

Taken measures according to warning: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow Does not affect any logic and behavior.


nautics889 commented 6 months ago

It seems that check failures above are not caused by this commit itself.

Logs from build 3.12 ``` return self.parse_json(res.text) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/pixivpy/pixivpy/pixivpy3/api.py", line 49, in parse_json return json.loads(json_str, object_hook=JsonDict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/__init__.py", line 359, in loads >>> 海沿いの街, origin url: https://i.pximg.net/c/600x1200_90/img-master/img/20[16](https://github.com/upbit/pixivpy/actions/runs/8583558571/job/23522908464?pr=348#step:7:17)/10/22/10/11/37/59580629_p0_master1200.jpg return cls(**kw).decode(s) ^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/runner/work/pixivpy/pixivpy/demo.py", line 343, in main() File "/home/runner/work/pixivpy/pixivpy/demo.py", line 330, in main appapi_illust(aapi) File "/home/runner/work/pixivpy/pixivpy/demo.py", line 34, in appapi_illust json_result = aapi.illust_comments(59580629) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/pixivpy/pixivpy/pixivpy3/aapi.py", line [28](https://github.com/upbit/pixivpy/actions/runs/8583558571/job/23522908464?pr=348#step:7:29)8, in illust_comments return self.parse_result(r) ^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/pixivpy/pixivpy/pixivpy3/aapi.py", line 98, in parse_result raise PixivError("parse_json() error: %s" % e, header=res.headers, body=res.text) pixivpy3.utils.PixivError: parse_json() error: Expecting value: line 1 column 1 (char 0) Error: Process completed with exit code 1. ```

And that pixivpy3.utils.PixivError: parse_json() error happens because here in illust_comments() it goes down with 404 Response for request to the endpoint app-api.pixiv.net/v1/illust/comments.

And the same happens when switch to latest release of PixivPy (3.7.5), so I bet it's unrelated to changes in this commit.


I've created a separate issue for that: https://github.com/upbit/pixivpy/issues/349 I guess it'd be good to hold this PR for a while, before solving that issue.