owenthereal / spotctl

A command-line interface to Spotify, written in Go
MIT License
243 stars 16 forks source link

HTTP 202: Accepted (body empty) and exit status 1 on most commands #1

Closed moon-musick closed 6 years ago

moon-musick commented 6 years ago

Hi,

I downloaded an amd64 linux release and am trying to set it up now. After a (supposedly) successful login (the browser says "Login successful, return to the terminal" etc.) any command intended to manipulate Spotify status (i.e. not help or version) yields 2017/12/26 14:30:03 spotify: HTTP 202: Accepted (body empty) message and immediately exits with exit status 1. The terminal session is a bit mangled afterwards and needs a reset to behave properly back again.

It's likely I am doing something wrong; perhaps I omitted some setup step. Could it be so?

I use Ubuntu 16.04 amd64 if it's of any importance.

owenthereal commented 6 years ago

That's prob. you didn't open the Spotify app. Could you try opening that and run the command again? One possible improvement to spotctl is to make sure the Spotify app is open before running. But I'm not familiar with the location of Spotify app in Ubuntu. Any hints?

owenthereal commented 6 years ago

Hmm...according to the API doc:

When the device is temporarily unavailable the request will return a 202 ACCEPTED response code and the client should retry the request after 5 seconds, but no more than at most 5 retries.

I tried clicking the play button in the Spotify app and run the spotctl command again and it works. May need a better way to fix this...

owenthereal commented 6 years ago

@moon-musick: https://github.com/jingweno/spotctl/pull/4 should address this. Please make sure your local Spotify app is opened. Thanks.

owenthereal commented 6 years ago

Forgot to mention, please make sure you have latest version of spotctl which includes the fix: https://github.com/jingweno/spotctl/releases

moon-musick commented 6 years ago

I didn't have the app open indeed.

I downloaded the 1.0.1 release, but it seems it was not enough to have the app open to make it work. I got it to work by clicking the play button in the app first, just as you mentioned; after that spotctl was able to pick up the status or show the player.

Thanks!