pixivpy icon indicating copy to clipboard operation
pixivpy copied to clipboard

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

Open Akise opened this issue 2 years ago • 6 comments

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

Akise avatar Jan 25 '23 10:01 Akise

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

Akise avatar Jan 25 '23 11:01 Akise

用旧手机抓到了 用户推荐 https://app-api.pixiv.net/v1/user/recommended?filter=for_android&offset=30 关注用户后推荐 https://app-api.pixiv.net/v1/user/related?filter=for_android&seed_user_id=1

Akise avatar Jan 25 '23 12:01 Akise

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

upbit avatar Jan 30 '23 13:01 upbit

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?

nautics889 avatar Mar 23 '23 18:03 nautics889

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?

nautics889 avatar Mar 23 '23 18:03 nautics889

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.

nautics889 avatar Mar 23 '23 20:03 nautics889