upbit / pixivpy

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

Feature request: `novel_recommended` method #248

Closed book000 closed 2 years ago

book000 commented 2 years ago

Hello, Thanks for developing and maintaining a great library.

Currently, illust_recommended is the method to retrieve recommended illustrations. However, there is no corresponding method for novels. I propose adding a method like novel_recommended.

I did some research on my own and it seems that I can get the expected data with the https://app-api.pixiv.net/v1/novel/recommended endpoint. In practice, the following simple code could be used to obtain it.

def novel_recommended(api: AppPixivAPI,
                      include_ranking_label=True):
    url = '%s/v1/novel/recommended' % api.hosts

    params = {
        'include_ranking_label': api.format_bool(include_ranking_label),
        'filter': 'for_ios',
    }

    r = api.no_auth_requests_call('GET', url, params=params, req_auth=True)
    return api.parse_result(r)

However, this is a simplified version for my own use, and it will be necessary to check parameters to actually incorporate it as a library.

I look forward to reply.

book000 commented 2 years ago

Endpoint parameters

The parameters that can be checked from next_url are listed for reference.

upbit commented 2 years ago

Endpoint parameters

The parameters that can be checked from next_url are listed for reference.

  • include_ranking_label = true
  • filter = for_ios
  • include_ranking_novels = false
  • offset = 15
  • already_recommended = 11111111,22222222 (comma separated novel ids)
  • max_bookmark_id_for_recommend = 2001285579
  • include_privacy_policy = false

Good job, let me verify these parameters

upbit commented 2 years ago

@book000 You can try the new version of master, by pip install git+https://github.com/upbit/pixivpy.git@master

I tried it out and it works fine, see novel_recommended() demo

I'am lack of verification environment for the novel_recommended(), please help to verify. If there is no problem, let me know and I will tag and release it.

book000 commented 2 years ago

OK, I have checked it in my environment and it works fine.

Thanks for your fast respond!

upbit commented 2 years ago

Fixed in v3.7.2