fm16191 / spotify-recorder

Recorder for Spotify. Not a YouTube downloader !!!
33 stars 6 forks source link

unrecognized arguments #1

Closed kaigiessen closed 2 years ago

kaigiessen commented 2 years ago

First of all, thanks for this awesome tool!

I installed everything according to the guide.

When trying to record an audio file I receive this error message:

user1@hostname:~/spotify-recorder$ py api.py https://open.spotify.com/track/X?si=X
/usr/bin/py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import Iterable
usage: py [-x] [-l] [-c PRE_CMD] [-C POST_CMD] [-V] [-h] [expression]
py: error: unrecognized arguments: https://open.spotify.com/track/X?si=X

@fm16191 - Any ideas?

fm16191 commented 2 years ago

Hi !

Please first try using python or python3 instead of py.

I forgot I was using py as an alias for python3... and according to your issue, it doesn't seems py is a python compiler on your device.

kaigiessen commented 2 years ago

Thanks - here is what I am getting when using python3 instead (waited 5 minutes for a 50sec track so I keyboard interrupted)

user1@hostaname:~/spotify-recorder$ python3 api.py https://open.spotify.com/track/X?si=X
Traceback (most recent call last):
  File "api.py", line 173, in <module>
    main()
  File "api.py", line 145, in main
    track = sp.search_sharelink(requested, "track.json")
  File "api.py", line 78, in search_sharelink
    track = self.sp.track(track_id)
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/client.py", line 345, in track
    return self._get("tracks/" + trid, market=market)
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/client.py", line 297, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/client.py", line 221, in _internal_call
    headers = self._auth_headers()
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/client.py", line 212, in _auth_headers
    token = self.auth_manager.get_access_token(as_dict=False)
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/oauth2.py", line 535, in get_access_token
    "code": code or self.get_auth_response(),
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/oauth2.py", line 490, in get_auth_response
    return self._get_auth_response_local_server(redirect_port)
  File "/home/pyload/.local/lib/python3.8/site-packages/spotipy/oauth2.py", line 459, in _get_auth_response_local_server
    server.handle_request()
  File "/usr/lib/python3.8/socketserver.py", line 294, in handle_request
    ready = selector.select(timeout)
  File "/usr/lib/python3.8/selectors.py", line 415, in select
    fd_event_list = self._selector.poll(timeout)
KeyboardInterrupt
fm16191 commented 2 years ago

Uh-oh. I'm not sure how I could reproduce that issue :(

I would need more information to help you.

By first getting last changes (git pull in the folder), can you try this : ./spotdl spotify:track:TRACK_ID test 5 in your terminal (replace the TRACK_ID using the share link, following that format : https://open.spotify.com/track/TRACK_ID?si=X) and provide me the output ?

Moreover, what is your shell ?

[EDIT : I missed a parameter. Fixed]

kaigiessen commented 2 years ago

Did the git pull

Then had to run sudo apt-get install jq sudo apt-get install pulseaudio-utils

Now getting

user1@hostname:~/spotify-recorder$ ./spotdl.sh spotify:track:X 5
Invalid usage, missing uri, filename or song duration.
Usage : ./spotdl.sh [URI] [filename] [song duration]
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Connection failure: Connection refused
...
...
user1@hostname:~/spotify-recorder$ echo "$SHELL"
/bin/bash
user1@hostname:~/spotify-recorder$ uname -a
Linux user1 5.4.0-113-generic #127-Ubuntu SMP Wed May 18 14:30:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
fm16191 commented 2 years ago

Sorry for the late answer.

It seems that your pulseaudio isn't working the way it should. According to the links below, you might have to reinstall pulseaudio : sudo apt-get --purge --reinstall install pulseaudio and then pulseaudio --start

https://askubuntu.com/questions/70560/why-am-i-getting-this-connection-to-pulseaudio-failed-error https://unix.stackexchange.com/questions/445386/pulseaudio-server-connection-failure-connection-refused-debian-stretch

fm16191 commented 2 years ago

Also, apologies. I failed the ./spotdl.sh command

Once you've tried out those commands, please retry doing ./spotdl.sh spotify:track:X test 5

kaigiessen commented 2 years ago

Just to clarify: Does this script support a headless setup? Installed a desktop version of Ubuntu and it's working.

fm16191 commented 2 years ago

Must depends on Spotify's ability to be runned headlessly as long as Spotify can be runned without graphical environment, the python and bash scripts would work seamlessly

fm16191 commented 2 years ago

Hi, did you managed to run Spotify headlessly ? I tried on my side, but unsuccessfully.

It can be very interesting if possible.

kaigiessen commented 2 years ago

Didn't get it to work headlessly. Having said that, it's working just fine on my desktop Ubuntu machine.

This thread can be closed.