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

Mixcloud failed to parse json #13867

Closed
kabachook opened this issue Aug 9, 2017 · 8 comments
Closed

Mixcloud failed to parse json #13867

kabachook opened this issue Aug 9, 2017 · 8 comments

Comments

@kabachook
Copy link

@kabachook kabachook commented Aug 9, 2017

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.08.06. 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.08.06

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

Log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.mixcloud.com/union77radio/noir-12-04-2016-quatri%C3%A8me/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.08.06
[debug] Python version 3.6.2 - Linux-4.10.8-docker-1-x86_64-with
[debug] exe versions: none
[debug] Proxy map: {}
[mixcloud] union77radio-noir-12-04-2016-quatrième: Downloading webpage
ERROR: union77radio-noir-12-04-2016-quatrième: Failed to parse JSON  (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)); 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/local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 676, in _parse_json
    return json.loads(json_string)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 676, in _parse_json
    return json.loads(json_string)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 357, 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 "/usr/local/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 776, in extract_info
    ie_result = ie.extract(url)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 433, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/extractor/mixcloud.py", line 82, in _real_extract
    self._decrypt_play_info(encrypted_play_info), track_id)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 680, in _parse_json
    raise ExtractorError(errmsg, cause=ve)
youtube_dl.utils.ExtractorError: union77radio-noir-12-04-2016-quatrième: Failed to parse JSON  (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)); 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

When downloading from Mixcloud json parser error occurs

@kabachook
Copy link
Author

@kabachook kabachook commented Aug 9, 2017

Probably connected with this js code that decrypt m-play-info contains

 function v(e, t) {
                var n, o, r = "pleasedontdownloadourmusictheartistswontgetpaid", i = r.length, a = 0, l = [];
                for (!t && f.player.value && (r = f.player.value,
                i = r.length),
                o = atob(e),
                n = o.length; n > a; a++)
                    l[a] = o.charCodeAt(a) ^ r.charCodeAt(a % i);
                var c = String.fromCharCode.apply(String, l);
                try {
                    return JSON.parse(c)
                } catch (s) {
                    if (t)
                        throw s;
                    return v(e, !0)
                }
@AndyRubio
Copy link

@AndyRubio AndyRubio commented Aug 9, 2017

The key pleasedontdownloadourmusictheartistswontgetpaid hasn't altered since yesterday when mixcloud was downloadable.

[UPDATE] c in kabachook's snippet initialises correctly. In my case, it contains https://stream1.mixcloud.com/c/m4a/64/1/5/7/f/6006-a40e-4a9b-a579-500c4db2ecf2.m4a which is the file I want to download.

[UPDATE] return JSON.parse(c) returns what appears to be valid JSON containing the valid .m4a url.

@kabachook
Copy link
Author

@kabachook kabachook commented Aug 9, 2017

It works only in browser for me. I run youtube-dl in a debugger and got wrongly decrypted string but code seems to be ok
[UPDATE] _decrypt_play_info returns '#(c{btlm_)?#.t>(}eik!9?+:Sgya$mtpu@�xawu gox�~9t6cfljk!hjbv>�-9$976kv7:d%",)>}e6s.f�m,$�t;3=@2=`=e�(0(Td4<91rujq\\'llh}7tyzp9Ql5.4P `yihze�w`<~�/$Ej��^8~&> 7=�4S3�+&($6fhk�(�mpm!@+M8`' insdead of {"stream_url": "https://stream4.mixcloud.com/c/m4a/64/3/6/1/d/5147-12b2-4309-a11e-54c6508a73e9.m4a", "id": 86305506, "html5_ping_session_id": "83C5B044-BBB3-4447-9938-5AC3BBFE8FE8"} as js script does

@kabachook
Copy link
Author

@kabachook kabachook commented Aug 9, 2017

[UPDATE]
Key value now is (function() { return new Date().toLocaleDateString(); })()
Everything seems to be working now

@kabachook
Copy link
Author

@kabachook kabachook commented Aug 9, 2017

Test passed

python test\test_download.py TestDownload.test_Mixcloud
[mixcloud] dholbach-cryptkeeper: Downloading webpage
[info] Writing video description metadata as JSON to: test_Mixcloud_dholbach-cryptkeeper.info.json
[debug] Invoking downloader on 'https://stream5.mixcloud.com/c/m4a/64/6/f/c/d/d610-b93d-40e5-9086-d731038019d9.m4a'
[download] Destination: test_Mixcloud_dholbach-cryptkeeper.m4a
[download] 100% of 10.00KiB in 00:00
.
----------------------------------------------------------------------
Ran 1 test in 2.407s

OK

New to github, need some help about how to make a pull request

@AndyRubio
Copy link

@AndyRubio AndyRubio commented Aug 9, 2017

What value does the key value have for you? new Date().toLocaleDateString() resolves to 09/08/2017 for me (I'm in the UK), my tests are still failing. I've tried different variations ...

@dstftw dstftw closed this in 5b3ddad Aug 9, 2017
@kabachook
Copy link
Author

@kabachook kabachook commented Aug 9, 2017

It's a string

@AndyRubio
Copy link

@AndyRubio AndyRubio commented Aug 9, 2017

Thanks - yep saw it on the fix. Good work!

@darnel darnel mentioned this issue Aug 11, 2017
4 of 8 tasks complete
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.