upbit/pixivpy

请问App-API有没有画师推荐的api?

Akise opened this issue · 6 comments

Akise commented

请问App-API有没有画师推荐的api?

Akise commented

发现app有画师推荐, 试着抓下app包, app显示读取失败估计是校验证书了
屏幕截图 2023-01-25 192703

upbit commented

这个应该后面新增的,我找时间补充进去。重开这个issue备忘下
感谢反馈~!

I've implemented one, it looks like it works more or less.

After calling user_recommended():

>>> api = AppPixivAPI()
>>> api.auth(refresh_token=REFRESH_TOKEN)
>>> print(json.dumps(api.user_recommended(), indent=2))

i've seen the next JSON (all data sanitized) in the reponse:
https://pastebin.com/HKNu5ynu

@upbit could you please have a look? Is it something what we expect considering the structure of JSON?

The linter (flake8) keeps failing anyway:

pixivpy3/aapi.py:303:5: C901 'AppPixivAPI.illust_recommended' is too complex (12)

Perhaps illust_recommended() should be slightly refactored.

Should we handle that as a part of the current issue?

The linter (flake8) keeps failing anyway:

pixivpy3/aapi.py:303:5: C901 'AppPixivAPI.illust_recommended' is too complex (12)

Perhaps illust_recommended() should be slightly refactored.

Should we handle that as a part of the current issue?

Done. All checks have passed.

Using conditional expression (aka "ternary operator") instead of if / elif has worked out.


Meanwhile i wouldn't say this is a conclusive solution for the problem that linter has exposed (not to mention conditional expressions reduce readability).
There are a lot of methods in AppPixivAPI doing the same job for setting up query-parameters to form the URL. That causes each of them have same/similar logic. I understand that this problem appeared as the library has been getting larger and there were more and more query-parameters to being added. Possibly the most comprehensive solution would be to move the common logic to utils.py module, but this is definetely out of scope of this issue.