L4cache / kemono-dl

(personal fork of) A simple kemono.party downloader using python.
95 stars 14 forks source link

Error while downloading Kemono (json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)) #28

Closed ghost closed 8 months ago

ghost commented 8 months ago

Version

Version:2022.04.28(https://github.com/L4cache/kemono-dl/commit/4b2fac797b678d7c848b02a6913602bab24e2705)

Your Command


py kemono-dl.py --cookies cookies.txt --kemono-fav-users all --dirname-pattern "X:\Kemono\_Recent" --filename-pattern "{published}_{id}_{username}_{title}_{index}.{ext}" --archive archive.txt --dateafter 20240104 --verbose

Description of bug

Fails to download a post.

How To Reproduce

Execute the above command. This will occur randomly, regardless of the specific user or post. If I run the command again immediately after the error occurs, I get the same error immediately. If I run the command after some time, it takes longer for the error to occur.

Error messages and tracebacks


ERROR:Unable to get favorite users from kemono.su
Traceback (most recent call last):
  File "C:\Users\[USERNAME]\AppData\Roaming\Python\Python311\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\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 "C:\Users\[USERNAME]\Downloads\kemono-dl-original\src\main.py", line 881, in start_download
    self.get_favorites(self.cookie_domains['kemono'], 'artist', retry=self.retry, services=self.k_fav_users)
  File "C:\Users\[USERNAME]\Downloads\kemono-dl-original\src\main.py", line 151, in get_favorites
    self.get_post(f"https://{domain}/{favorite['service']}/user/{favorite['id']}")
  File "C:\Users\[USERNAME]\Downloads\kemono-dl-original\src\main.py", line 182, in get_post
    json = self.session.get(url=f"{api}?o={chunk}", cookies=self.cookies, headers=self.headers, timeout=self.timeout).json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[USERNAME]\AppData\Roaming\Python\Python311\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Additional comments

There are currently over 300 favorite artists. If I take the interval between runs, the error will take longer to appear, so perhaps access is restricted from the kemono side. In any case, the same error occurs and the download never completes.

debug.log

L4cache commented 8 months ago

Can you have the api call returned valued saved next time you encounter this? (like access the api link from browser and save the content, or download the api link in download tool) I will look into this as well, with the information it should be easier

L4cache commented 8 months ago

Yeah that's probably 429

L4cache commented 8 months ago

"Fixed" I can't fix the server giving you 429 of course, hence the quote.