Miserlou / SoundScrape

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

Unable to Use Likes Argument #249

Open wesleymartin234 opened 3 years ago

wesleymartin234 commented 3 years ago

soundscrape idkidc1 -l

results in:

Expecting value: line 1 column 1 (char 0) Process finished with exit code 0

I've also attempted using --likes

Note:

This artist has a high number of likes.

Could this be a problem with failure to return JSON payload from the likes page ?

How to debug?

Any response or assistance is appreciated.

wesleymartin234 commented 3 years ago

Additional Info:

`Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 37, in _scan_once nextchar = string[idx] IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/soundscrape/soundscrape.py", line 174, in process_soundcloud resolved2 = requests.get(next_href).json() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 79, in scan_once return _scan_once(string, idx) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 39, in _scan_once raise JSONDecodeError(errmsg, string, idx) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 37, in _scan_once nextchar = string[idx] IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/bin/soundscrape", line 33, in sys.exit(load_entry_point('soundscrape==0.30.1', 'console_scripts', 'soundscrape')()) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/soundscrape/soundscrape.py", line 119, in main process_soundcloud(vargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/soundscrape/soundscrape.py", line 198, in process_soundcloud hard_track_url = get_hard_track_url(item_id) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/soundscrape/soundscrape.py", line 519, in get_hard_track_url json_response = response.json() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 79, in scan_once return _scan_once(string, idx) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/simplejson/scanner.py", line 39, in _scan_once raise JSONDecodeError(errmsg, string, idx) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`

markddavidoff commented 3 years ago

looks like same issue as https://github.com/Miserlou/SoundScrape/issues/253

markddavidoff commented 3 years ago

Seems like this happens: use requests to get the user id of the user you want likes for: userId = str(client.get('/resolve', url=artist_url).id) use soundclound client to get a page of the user's favorites resolved = client.get('/users/' + userId + '/favorites', limit=200, linked_partitioning=1) if there is a next_href to indicate there is a next page (there is in this case), get info on that page as json. resolved2 = requests.get(next_href).json() ^ this actually fails with : 401: {'code': 401, 'message': '', 'link': 'https://developers.soundcloud.com/docs/api/explorer/open-api', 'status': '401 - Unauthorized', 'errors': [], 'error': None} then we try to access "collection" on that dict which does not exist

markddavidoff commented 3 years ago

so 2 things i see wrong with this, 1) so it seems pagination is not correctly implemented as requests does not have the permission that the soundcloud client has 2) '/users/' + userId + '/favorites', is deprecated, (use /users/:userId/likes/tracks instead, to fetch a user's likes)

markddavidoff commented 3 years ago

@Miserlou potential fix: https://github.com/Miserlou/SoundScrape/pull/254

markddavidoff commented 3 years ago

@wesleymartin234 here I've updated my pr, this should work #254, but that user has 2029 likes are you sure you want to download all that?