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

[GameStar] ERROR: 92640: Failed to parse JSON (caused by JSONDecodeError('Invalid control character at...') #12671

Open
aeph6Ee0 opened this issue Apr 6, 2017 · 0 comments · May be fixed by #12709
Assignees
Labels
bug

Comments

@aeph6Ee0
Copy link
Contributor

@aeph6Ee0 aeph6Ee0 commented Apr 6, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.04.03. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2017.04.03

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

Downloading of some Gamestar videos fail with the following error message:

$ youtube-dl -v http://www.gamestar.de/videos/rain-world-gameplay-trailer-stellt-das-sandbox-spiel-vor,92640.html
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'http://www.gamestar.de/videos/rain-world-gameplay-trailer-stellt-das-sandbox-spiel-vor,92640.html']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.04.03
[debug] Python version 3.6.0 - Linux-4.10.6-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.2.4, ffprobe 3.2.4, rtmpdump 2.4
[debug] Proxy map: {}
[GameStar] 92640: Downloading webpage
ERROR: 92640: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at: line 6 column 140 (char 280)',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 672, in _parse_json
    return json.loads(json_string)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 6 column 140 (char 280)
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 672, in _parse_json
    return json.loads(json_string)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 6 column 140 (char 280)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 761, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 429, in extract
    ie_result = self._real_extract(url)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/gamestar.py", line 38, in _real_extract
    webpage, 'JSON-LD', group='json_ld'), video_id)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 676, in _parse_json
    raise ExtractorError(errmsg, cause=ve)
youtube_dl.utils.ExtractorError: 92640: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at: line 6 column 140 (char 280)',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Identified problem

  • New line characters in json string.

Reference

Possible fixes

  • Ignore new line characters: Change json.loads(json_string) to json.loads(json_string, strict=False) in extractors/common.py.
    • This might conceal other errors? -> Create a new key word argument called strict=True in def _parse_json().
  • Remove new line characters in json string (in extractors/gamestar.py):
       json_ld = self._parse_json(self._search_regex(
           r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
           webpage, 'JSON-LD', group='json_ld'), video_id,
           transform_source=lambda s: s.replace('\n', ''))
  • or
        json_ld = self._parse_json(self._search_regex(
            r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
            webpage, 'JSON-LD', group='json_ld').replace('\n', ''), video_id)
@aeph6Ee0 aeph6Ee0 linked a pull request that will close this issue Apr 10, 2017
4 of 8 tasks complete
@yan12125 yan12125 added the bug label May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.