Miserlou / SoundScrape

SoundCloud (and Bandcamp and Mixcloud) downloader in Python.
MIT License
1.42k stars 146 forks source link

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #237

Closed verybigelephants closed 4 years ago

verybigelephants commented 5 years ago

soundscrape https://soundcloud.com/gesaffelstein/sets/hyperion-8 gives me this error

Active code page: 65001
Traceback (most recent call last):
  File "c:\programs\python3\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programs\python3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\programs\python3\Scripts\soundscrape.exe\__main__.py", line 9, in <module>
  File "c:\programs\python3\lib\site-packages\soundscrape\soundscrape.py", line 119, in main
    process_soundcloud(vargs)
  File "c:\programs\python3\lib\site-packages\soundscrape\soundscrape.py", line 250, in process_soundcloud
    tracks = get_soundcloud_api_playlist_data(resolved.id)['tracks']
  File "c:\programs\python3\lib\site-packages\soundscrape\soundscrape.py", line 507, in get_soundcloud_api_playlist_data
    parsed = response.json()
  File "c:\programs\python3\lib\site-packages\requests\models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "c:\programs\python3\lib\site-packages\simplejson\__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "c:\programs\python3\lib\site-packages\simplejson\decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "c:\programs\python3\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
verybigelephants commented 5 years ago

i have found the culprint, this happens when the tracks are unavailable (like when it's not available in your country for example)

perhaps a better error message would be good for this?

SimplicityGuy commented 4 years ago

Unfortunately, there is a ton of these edge cases with the current SoundCloud API. SoundScrape does the best it could but without a better API from SoundCloud, understanding what each of these errors means is tricky.

PR #241 addresses a number of fixes, including better handling of errors from bad responses.