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

HTTPError: 401 Client Error: Unauthorized for url #292

Closed
10frank10 opened this issue Nov 30, 2019 · 28 comments
Closed

HTTPError: 401 Client Error: Unauthorized for url #292

10frank10 opened this issue Nov 30, 2019 · 28 comments

Comments

@10frank10
Copy link

Have used scdl flawlessly before but now seem to be getting 401 client error. Saw this was a similar issue in the Soundcloud Downloader that is part of Youtube DL here on GitHub. Someone was able to resolve the error, but I was unable to replicate the update they pushed when trying to fix scdl. Here is my console output below.

Franks-MacBook-Pro-2:~ dank$ scdl -l https://soundcloud.com/holmes-john/jacky-holmes-john-mumma
Soundcloud Downloader
Found a track
Downloading Jacky & Holmes John - Mumma
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/scdl", line 11, in
load_entry_point('scdl==1.6.12', 'console_scripts', 'scdl')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 179, in main
parse_url(arguments['-l'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 262, in parse_url
download_track(item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 496, in download_track
r.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/562174671/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z
Franks-MacBook-Pro-2:~ dank$

@10frank10
Copy link
Author

10frank10 commented Nov 30, 2019

Also wanted to add onto this report that I'm now getting another error while trying to run the same command again. Here's output again

Franks-MacBook-Pro-2:~ dank$ scdl -l https://soundcloud.com/jordan-brando/jordan-brando-encode-original-mix-club-sweat
Soundcloud Downloader
Found a track
Downloading Jordan Brando - Encode (Original Mix) [Club Sweat]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 394, in connect
ssl_context=context,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in init
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 394, in connect
ssl_context=context,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in init
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/scdl", line 11, in
load_entry_point('scdl==1.6.12', 'console_scripts', 'scdl')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 179, in main
parse_url(arguments['-l'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 262, in parse_url
download_track(item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scdl/scdl.py", line 493, in download_track
url, params={'client_id': ALT_CLIENT_ID}, stream=True
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
Franks-MacBook-Pro-2:~ dank$

@Davicii-ii
Copy link

yup
401 Client Error: Unauthorized for url: https://api.soundcloud.com/tracks/486761280/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z Traceback (most recent call last): File "/home/ayuko/.local/lib/python3.6/site-packages/scdl/scdl.py", line 357, in download download_track(item) File "/home/ayuko/.local/lib/python3.6/site-packages/scdl/scdl.py", line 496, in download_track r.raise_for_status() File "/home/ayuko/.local/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/486761280/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z

@Davicii-ii
Copy link

Is Soundcloud preventing the downloads bcoz the API isn't available?

@flyingrub
Copy link
Collaborator

flyingrub commented Nov 30, 2019

30968bc introduce a fix for this and the issue with unauthorized track since a few days.
For now there is no progress bar anymore and we need ffmpeg to decode HLS stream.

You will have to install it from source as this version is still not on pipy. If you do it don't forget to pip uninstall scdl before, to be sure run the command twice in a row.

@jolespin
Copy link

I also have this error but this fixed it:

pip uninstall scdl
pip install git+https://github.com/flyingrub/scdl

@khamsathous
Copy link

I got that error to go away by updating python, uninstalling, then reinstalling, but I then got a parse error I fixed by

pip install configparser

but now I have yet another error

john$ scdl
Traceback (most recent call last):
File "/usr/local/bin/scdl", line 5, in
from scdl.scdl import main
File "/usr/local/lib/python2.7/site-packages/scdl/scdl.py", line 73, in
from scdl import version, CLIENT_ID, ALT_CLIENT_ID
ImportError: cannot import name version

Anyone know how to fix this?

@jolespin
Copy link

jolespin commented Dec 1, 2019 via email

@silverbacknet
Copy link

30968bc introduce a fix for this and the issue with unauthorized track since a few days.
For now there is no progress bar anymore and we need ffmpeg to decode HLS stream.

Why pull the enormity of ffmpeg in, and using shell piping instead of its api, when there are already pure-python HLS parsers like https://github.com/globocom/m3u8 ?

@Davicii-ii
Copy link

30968bc introduce a fix for this and the issue with unauthorized track since a few days.
For now there is no progress bar anymore and we need FFmpeg to decode HLS stream.

Why pull the enormity of FFmpeg in, and using shell piping instead of its API, when there are already pure-python HLS parsers like https://github.com/globocom/m3u8?

i think there's a ffmpeg lib in python

@flyingrub
Copy link
Collaborator

Why pull the enormity of ffmpeg in, and using shell piping instead of its api, when there are already pure-python HLS parsers like https://github.com/globocom/m3u8 ?

Here is a few reasons :

  1. I tried to use the m3u8 python library, which is just a parser for the HLS m3u8 file that contains a bunch of link to 10sec mp3. I tried to concatenate the file directly but apparently they overlap in some way. So you end up with a not so pleasant file that does not correspond to the song you want.
  2. I then tried to use ffmpeg which handle everything for us and works perfectly.
  3. We could use a python wrapper around it, but why use another dependency, as you would still need ffmpeg anyway ? ;)
  4. I develop this script in my free time and when I saw that soundcloud broke the compatibility with my script, I was looking for the easiest, fastest to write, more sustainable fix for it, which I think this commit was.

If you have any idea on how to do this in a cleaner way feel free to open a Pull Request.

@kris-sum
Copy link

kris-sum commented Dec 4, 2019

@khamsathous

ImportError: cannot import name version

I think you're using python 2, not python 3.

@GloBang
Copy link

GloBang commented Dec 4, 2019

@flyingrub yo, what is better to download http_mp3_128 or hls_mp3_128?

@flyingrub
Copy link
Collaborator

@flyingrub yo, what is better to download http_mp3_128 or hls_mp3_128?

http_mp3_128 is not available for every track, that is why I am using hls_mp3_128.

@jorubyp
Copy link

jorubyp commented Dec 5, 2019

shlex.quote() doesn't seem to be working for me like it is for the rest of you, ampersands in the url are still being treated as control operators.

@CROSP
Copy link
Contributor

CROSP commented Dec 7, 2019

Check my fork, I replaced quotes from shlex.quote to simple hardcoded quotes as a temp solution for the windows environment https://github.com/CROSP/scdl

@jorubyp
Copy link

jorubyp commented Dec 8, 2019

@CROSP Thanks very much, working here too.

@MrAureliusR
Copy link

MrAureliusR commented Dec 9, 2019

Check my fork, I replaced quotes from shlex.quote to simple hardcoded quotes as a temp solution for the windows environment https://github.com/CROSP/scdl

Your fork is not working for me, getting an ffmpeg File not found error. It seems to be trying to pass this enormous URL as the input to ffmpeg.
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg -i "https://cf-hls-media.sndcdn.com/playlist/kA27FgKlZ3ow.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L2tBMjdGZ0tsWjNvdy4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzU4NTQ1NTN9fX1dfQ__&Signature=RbNOj8kO5RiZuqqTNHw-TboITGUevi9xJVNJ94IHRc11cvh~Bu974cRJTejZf503DP2xDYLHfylFY5oVIU26EAYLf6xjIbe9reS5vPVJyWq4HDi6fNeZdTVod72FxNDwyImQophfpPRC3Vsvn~id0QAZyQzngF5NY5fgwplrncK3BM~x9DXPpzo9gLRKsvB5y5RPPzB0ELUNIwSzy97~SfLJH3t~6ARs7ww4sEGbn6S-GdSXP2XpU7VzuYD5a9r5KnJWxE28QbH7VCx5fqhiR3mty-Jy6HllVzeN9Xn3f3VtTt6c8Io9QJIZi4GAHN0N8Fi~pwQRg7pjE-xnbN7rsg__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ" -c copy "King Of The World.mp3" -loglevel fatal': 'ffmpeg -i "https://cf-hls-media.sndcdn.com/playlist/kA27FgKlZ3ow.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L2tBMjdGZ0tsWjNvdy4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzU4NTQ1NTN9fX1dfQ__&Signature=RbNOj8kO5RiZuqqTNHw-TboITGUevi9xJVNJ94IHRc11cvh~Bu974cRJTejZf503DP2xDYLHfylFY5oVIU26EAYLf6xjIbe9reS5vPVJyWq4HDi6fNeZdTVod72FxNDwyImQophfpPRC3Vsvn~id0QAZyQzngF5NY5fgwplrncK3BM~x9DXPpzo9gLRKsvB5y5RPPzB0ELUNIwSzy97~SfLJH3t~6ARs7ww4sEGbn6S-GdSXP2XpU7VzuYD5a9r5KnJWxE28QbH7VCx5fqhiR3mty-Jy6HllVzeN9Xn3f3VtTt6c8Io9QJIZi4GAHN0N8Fi~pwQRg7pjE-xnbN7rsg__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ" -c copy "King Of The World.mp3" -loglevel fatal'

That is from this link: https://soundcloud.com/porcelainblackfans/sets/porcelain-black-porcelain-and-the-tramps

@GiovanH
Copy link

GiovanH commented Dec 21, 2019

The "fix" of using ffmpeg doesn't seem to work at all: I updated scdl when I got the error mentioned in this issue, but the latest version just has the ffmpeg error as explained in issue #291

@CristianNanan
Copy link

Here are the steps I had to take to get this working again:

  1. uninstall the current version
    pip uninstall scdl

  2. install CROSP's fork
    pip install git+https://github.com/CROSP/scdl

  3. download ffmpeg and add the bin folder to your path
    https://www.ffmpeg.org/download.html

After doing this it works for me.

@UkwaA
Copy link

UkwaA commented Jan 11, 2020

Here are the steps I had to take to get this working again:

  1. uninstall the current version
    pip uninstall scdl
  2. install CROSP's fork
    pip install git+https://github.com/CROSP/scdl
  3. download ffmpeg and add the bin folder to your path
    https://www.ffmpeg.org/download.html

After doing this it works for me.

Edit: Nvm I figured out where to get the bin file from, my only remaining question is which path to put it in

@silverbacknet
Copy link

Edit: Nvm I figured out where to get the bin file from, my only remaining question is which path to put it in

Anywhere that scdl can see it from. You can even drop scdl and everything in bin into the same folder and scdl will use it just fine. ffmpeg's very useful in general, so I have it in the system path; the user path would work, except for anything run as administrator. (I actually have some tricky junctions set up to go to different folders depending on x86 or x64, but practically everything's x64 now anyway.)

Oh, and by "path" we mean the thing you get to when you right click the start button, choose settings, click system info on the top right, click advanced system settings on the left, and open the "Environment Variables." One of them is PATH, and the system combines the system and user version to look up missing files before it fails.

Some installers of ffmpeg will do the add to path for you, but I forget which ones.

@mavieth
Copy link

mavieth commented Jan 16, 2020

I opened up a PR that appears to fix these issues. #304

@imranhafiz
Copy link

Here are the steps I had to take to get this working again:

  1. uninstall the current version
    pip uninstall scdl
  2. install CROSP's fork
    pip install git+https://github.com/CROSP/scdl
  3. download ffmpeg and add the bin folder to your path
    https://www.ffmpeg.org/download.html

After doing this it works for me.

thanks to all of you for your help, particularly @flyingrub and @CROSP!

I'm definitely a beginner here, having the same issue but on Mac. I'm using pip3 instead of pip (because the Mac's system pip is 2.7, whereas the new python i've installed is now 3.8).

What is ffmpeg, and how do I install it? Moreover, how do I "add the bin folder to my path" on Mac? Currently, SCDL seems to be downloading to my user folder on Mac.

@flyingrub
Copy link
Collaborator

you should be install to run brew install ffmpeg after having installed https://brew.sh/

@imranhafiz
Copy link

imranhafiz commented Jan 17, 2020

you should be install to run brew install ffmpeg after having installed https://brew.sh/

done! ffmpeg is installed now, through homebrew. How do I set the ffmpeg's bin file into scdl's path? more specifically, what should I type into terminal in order to get scdl to see ffmpeg?

currently, scdl is outputting to my username (where my application folder is) on my Mac (running mojave 10.14.5).

Here's what I'm getting in terminal:
Soundcloud Downloader Found a playlist Track n°1 Retrieving more info on the track Downloading DO IT Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/bin/scdl", line 11, in <module> load_entry_point('scdl==1.6.12', 'console_scripts', 'scdl')() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scdl/scdl.py", line 180, in main parse_url(arguments['-l']) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scdl/scdl.py", line 266, in parse_url download_playlist(item) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scdl/scdl.py", line 387, in download_playlist download_track(track_raw, playlist['title'], playlist_file) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scdl/scdl.py", line 544, in download_track filename = download_hls_mp3(track, title) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scdl/scdl.py", line 514, in download_hls_mp3 res = subprocess.call( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 340, in call with Popen(*popenargs, **kwargs) as p: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg -i "https://cf-hls-media.sndcdn.com/playlist/cAbsSedVxGPA.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L2NBYnNTZWRWeEdQQS4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzkyOTUwNDJ9fX1dfQ__&Signature=G7jBftoZNjLGA8OH71oOrF43lHguNnWMzCJkV9cE45N9hPKLnK5~0GUespxB89rhWI3r8Q7oYz6nHnB9O9IQ74e41abbCQO~q6ZbLoEwycl9bRDEOLlw-IKivIPyqswwekAwdh-oE-riCeHNpbYPz~WkWLlULkG-KO~nUaVDrklx~Qg1FgIux8AV-b94EAI5k04uEwTkDSMBnrzogEfc2wYxHVXcZIyTrjKQRYKALaY8m0ZAgCSlCcw9AgAE0TaB48Tk2LTF1EWeEpvalnWGG3oqGf-72~6gZ2XOMAGOsVENX5yS7rYuHgk8ZdYdNtVL5vi7denJDc9yMQxNZgMk~A__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ" -c copy "DO IT.mp3" -loglevel fatal'

@flyingrub
Copy link
Collaborator

flyingrub commented Jan 21, 2020

Latest commit on master should fix those issues. c221e43

@GiovanH
Copy link

GiovanH commented Jan 29, 2020

Issue unresolved, still gives error on latest version:

Downloading xxx
401 Client Error: Unauthorized for url: https://api.soundcloud.com/tracks/xxx/stream?client_id=xxx
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\scdl-1.6.11-py3.7.egg\scdl\scdl.py", line 357, in download
    download_track(item)
  File "c:\program files\python37\lib\site-packages\scdl-1.6.11-py3.7.egg\scdl\scdl.py", line 496, in download_track
    r.raise_for_status()
  File "c:\program files\python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)

Note: Python 3.8 does seem to work. This may be affected by recent oddities with how the request module handles security.

@TheMasterDan
Copy link

pip uninstall scdl
apt install python3-pip --reinstall
pip3 uninstall scdl
pip3 install git+https://github.com/flyingrub/scdl
scdl
done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests