bebound / pixivd

Pixiv Downloader - Batch download pictures from Pixiv
MIT License
138 stars 18 forks source link

Failed to fetch daily ranking #28

Closed KanTakahiro closed 3 years ago

KanTakahiro commented 3 years ago

I am using pixiv version 2.4 for downloading daily ranking and got an error like this:

$ python3 pixiv.py -r -d 2021-7-31 
18:46:48 07/31/21
[invalid]
Traceback (most recent call last):
  File "pixiv.py", line 380, in <module>
    sys.exit(main())
  File "pixiv.py", line 344, in main
    download_by_history_ranking(user, date)
  File "pixiv.py", line 258, in download_by_history_ranking
    data_list = user.get_ranking_illustrations(date=date, per_page=100, mode='daily')
  File "/home/takahiro/Git/pixiv/api.py", line 518, in get_ranking_illustrations
    return self.parse_result(r)
  File "/home/takahiro/Git/pixiv/api.py", line 206, in parse_result
    raise Pixiv_Get_Error(r.url, data['errors'])
api.Pixiv_Get_Error: Failed to get data: https://public-api.secure.pixiv.net/v1/ranking/all?mode=daily&page=1&per_page=100&include_stats=True&include_sanity_level=True&image_sizes=px_128x128%2Cpx_480mw%2Csmall%2Cmedium%2Clarge&profile_image_sizes=px_170x170%2Cpx_50x50&date=2021-07-31

The function of fetching image by user ID works fine. I think this maybe a bug of function of "downloading by ranking". The link https://public-api.secure.pixiv.net/v1/ranking/all?mode=daily&page=1&per_page=100&include_stats=True&include_sanity_level=True&image_sizes=px_128x128%2Cpx_480mw%2Csmall%2Cmedium%2Clarge&profile_image_sizes=px_170x170%2Cpx_50x50&date=2021-07-31 pointed to a JSON file like this:

{"status":"failure","has_error":true,"errors":{"system":{"message":"The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed."}}}
bebound commented 3 years ago

Thank you.

The cause is 2021-7-31 is not a valid date format, and my script use 2021-07-31 as default date. However, today's date is not available. I've change the default ranking date to yesterday, it should work now.