Miserlou / SoundScrape

SoundCloud (and Bandcamp and Mixcloud) downloader in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

soundcloud soundscrape no longer working (401 unauthorized)

g-mac opened this issue · comments

commented

Hey, it seems to me like soundscraping soundcloud is no longer working. Following the issue throughout the code its seems that a 401 http error, unauthorized is the issue, which is the response received in line 526 [get_hard_track_url()].
Does this have something todo with the new security update from soundcloud? https://developers.soundcloud.com/blog/security-updates-api

would be super happy if a fix for this issue was found.

best wishes,
simon

macbook:3.6 simon$ soundscrape https://soundcloud.com/afterhour-sounds/premiere-ele-bisu-app_version=1481046241
Scraping: Stream PREMIERE: ele & bisu - Cardamom Coffee [ Talpa Rec. ]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundscrape/soundscrape.py", line 188, in process_soundcloud
    resolved = client.get('/resolve', url=artist_url, limit=200)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundcloud/client.py", line 133, in _request
    return wrapped_resource(make_request(method, url, kwargs))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundcloud/request.py", line 148, in make_request
    result.raise_for_status()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.soundcloud.com/tracks/1021056175

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/soundscrape", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundscrape/soundscrape.py", line 123, in main
    process_soundcloud(vargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundscrape/soundscrape.py", line 222, in process_soundcloud
    filename = download_file(hard_track_url, filename)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundscrape/soundscrape.py", line 1227, in download_file
    if url[0:2] == '//':
TypeError: 'NoneType' object is not subscriptable
commented

@Miserlou is this the end of it? the end of soundscrape for soundcloud? i cannot get my head around it, but it looks like they ve changed a bunch of things and upped their security.. what do you think? fixable? hackable?

Seriously tho i just wanted to get all my songs on my phone this was my go to for a very long time, i hope this gets fixed soon.

commented

right, thanks for the input - i ended up using a different tool for soundcloud downloads for now.
However I would enjoy if soundscrape was fixed - and the broken link was really not the problem, the 401 unauthorized is real.

commented

right, thanks for the input - i ended up using a different tool for soundcloud downloads for now. However I would enjoy if soundscrape was fixed - and the broken link was really not the problem, the 401 unauthorized is real.

@g-mac which tool did you use? thank you !

commented

https://github.com/ytdl-org/youtube-dl

youtube-dl --add-metadata --embed-thumbnail [soundcloud url] seems to do the trick (with caveats).

  • you need ffmpeg installed for it to be able to edit metadata
  • attempting to add both metadata and embed the thumbnail at the same time results in a permission error, I work around by running the command a second time

edit: I haven't been getting the permission error. Also, I don't like when it ends up downloading a .wav file. Youtube-dl will convert the wav to mp3 and then apply the metadata + thumbnail for you if you use the following command:
youtube-dl --no-mtime --add-metadata --embed-thumbnail -x --audio-format mp3 --audio-quality 2 [soundcloud url]

See the github page for how --audio-quality works. Note that if what you download is already an mp3, then it won't attempt to convert it and apply the audio-quality setting. So basically, always use the newer command with audio-format and audio-quality, and it will convert a wav for you if that's what you pull, but do nothing different otherwise.

youtube-dl and incantation posted by @hbak works for me (no permission error). I installed youtube-dl via brew and it installed ffmpeg as part of that. Thanks for the tip!
The Soundcloud api changes are ostensibly so "we can relaunch API access to all developers", which might be a good thing in the end.

Why isn't youtube-dl running into the same error as Soundscrape?

commented