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

[utils] js_to_json can't handle scientific notations (was: [twitch:clips] JSONDecodeError for certain clips) #14789

Closed
s104346 opened this issue Nov 18, 2017 · 0 comments
Labels
bug

Comments

@s104346
Copy link

@s104346 s104346 commented Nov 18, 2017

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

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the 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

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add the -v flag to your command line you run youtube-dl with (youtube-dl -v <your command line>), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

$ python -m youtube_dl --verbose https://clips.twitch.tv/CarelessZealousKangarooNerfBlueBlaster
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://clips.twitch.tv/CarelessZealousKangarooNerfBlueBlaster']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.11.15
[debug] Git HEAD: f610dbb05
[debug] Python version 3.6.3 - Linux-4.12.13-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.4, ffprobe 3.4, rtmpdump 2.4
[debug] Proxy map: {}
[twitch:clips] CarelessZealousKangarooNerfBlueBlaster: Downloading webpage
ERROR: CarelessZealousKangarooNerfBlueBlaster: Failed to parse JSON  (caused by JSONDecodeError("Expecting ',' delimiter: line 38 column 78 (char 2178)",)); 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 "/tmp/youtube-dl/youtube_dl/extractor/common.py", line 686, 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: Expecting ',' delimiter: line 38 column 78 (char 2178)
Traceback (most recent call last):
  File "/tmp/youtube-dl/youtube_dl/extractor/common.py", line 686, 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: Expecting ',' delimiter: line 38 column 78 (char 2178)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/youtube-dl/youtube_dl/YoutubeDL.py", line 784, in extract_info
    ie_result = ie.extract(url)
  File "/tmp/youtube-dl/youtube_dl/extractor/common.py", line 437, in extract
    ie_result = self._real_extract(url)
  File "/tmp/youtube-dl/youtube_dl/extractor/twitch.py", line 610, in _real_extract
    video_id, transform_source=js_to_json)
  File "/tmp/youtube-dl/youtube_dl/extractor/common.py", line 690, in _parse_json
    raise ExtractorError(errmsg, cause=ve)
youtube_dl.utils.ExtractorError: CarelessZealousKangarooNerfBlueBlaster: Failed to parse JSON  (caused by JSONDecodeError("Expecting ',' delimiter: line 38 column 78 (char 2178)",)); 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.

Description of your issue, suggested solution and other information

Most twitch clips work just fine, but this specific one causes problems (https://clips.twitch.tv/CarelessZealousKangarooNerfBlueBlaster).

Looking at the js/json string being parsed suggests that its segments value, which is null for all working clips including youtube-dl's test URLs, is the culprit. The original form of this line is

segments: [{"playback_offset":0,"offset":-3.885780586188048e-16,"duration":39.75000000000001,"speed":1}],

which gets transformed into

"segments": [{"playback_offset":0,"offset":-3.885780586188048"e"-16,"duration":39.75000000000001,"speed":1}],

This adds quotation marks around the exponent marker which causes the error.

@yan12125 yan12125 changed the title [twitch:clips] JSONDecodeError for certain clips [utils] js_to_json can't handle scientific notations (was: [twitch:clips] JSONDecodeError for certain clips) Nov 27, 2017
@yan12125 yan12125 added the bug label Nov 27, 2017
@dstftw dstftw mentioned this issue Dec 2, 2017
0 of 4 tasks complete
@dstftw dstftw closed this in c384d53 Jan 20, 2018
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.

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