Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zerochan] JSONDecodeError: Invalid control character '\r' #5892

Closed
taskhawk opened this issue Jul 26, 2024 · 1 comment
Closed

[Zerochan] JSONDecodeError: Invalid control character '\r' #5892

taskhawk opened this issue Jul 26, 2024 · 1 comment
Labels

Comments

@taskhawk
Copy link

I ran into this error when doing a run for an artist tag. Looking into it, it seems it's in one particular post, and it only happens when enabling metadata with the zerochan.metadata config option.

This works fine (needs an account):

gallery-dl -u "user" -p "pass" -K "https://www.zerochan.net/1395035"

This causes the error:

gallery-dl -u "user" -p "pass" -o metadata=true -K "https://www.zerochan.net/1395035"
[zerochan][error] Unable to download data:  JSONDecodeError: Invalid control character '\r' at: line 11 column 56 (char 430)

Verbose output of the previous command (using 1.27.1 but with the latest code available for the zerochan extractor):

[gallery-dl][debug] Version 1.27.1
[gallery-dl][debug] Python 3.8.10 - Linux-5.15.0-113-generic-x86_64-with-glibc2.29
[gallery-dl][debug] requests 2.32.3 - urllib3 2.1.0
[gallery-dl][debug] Configuration Files ['${HOME}/.config/gallery-dl/config.json']
[gallery-dl][debug] Starting KeywordJob for 'https://www.zerochan.net/1395035'
[zerochan][debug] Using ZerochanImageExtractor for 'https://www.zerochan.net/1395035'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.zerochan.net:443
[urllib3.connectionpool][debug] https://www.zerochan.net:443 "GET /1395035 HTTP/1.1" 200 None
[zerochan][debug] Sleeping 1.00 seconds (request)
[urllib3.connectionpool][debug] https://www.zerochan.net:443 "GET /1395035?json HTTP/1.1" 200 None
[zerochan][error] Unable to download data:  JSONDecodeError: Invalid control character '\r' at: line 11 column 56 (char 430)
[zerochan][debug] 
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Invalid control character '\r' at: line 11 column 56 (char 430)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/gallery_dl/job.py", line 150, in run
    for msg in extractor:
  File "/home/user/.local/lib/python3.8/site-packages/gallery_dl/extractor/booru.py", line 34, in items
    for post in self.posts():
  File "/home/user/.local/lib/python3.8/site-packages/gallery_dl/extractor/zerochan.py", line 234, in posts
    post.update(self._parse_entry_api(self.image_id))
  File "/home/user/.local/lib/python3.8/site-packages/gallery_dl/extractor/zerochan.py", line 95, in _parse_entry_api
    item = self.request(url).json()
  File "/home/user/.local/lib/python3.8/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Invalid control character '\r' at: line 11 column 56 (char 430)

This is the only instance I have run into but suspect there may be others.

@mikf
Copy link
Owner

mikf commented Jul 30, 2024

The source field for https://www.zerochan.net/1395035 contains a stray \r for whatever reason.

@mikf mikf closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants