fabiofalci / sconsify

A spotify console application
https://fabiofalci.github.io/sconsify
Apache License 2.0
566 stars 26 forks source link

How to play only 1 of my playlists? Save password? Create Access Token that won't expire? #85

Closed feirsom closed 6 years ago

feirsom commented 6 years ago

3 questions:

  1. How do I save my password in the script, so i don't have to re-enter it? (currently, I have to enter it every time)

  2. How do I create an Access Token that won't ever expire?

  3. How do I load only 1 specified playlist in No UI mode, so that it won't eventually shuffle to other playlists in my library? How do I script it, so that it only plays and repeats the one specified playlist without deleting the other playlists from my library?

Current Code: ./sconsify -ui=false -username=username SCONSIFY_PASSWORD=password -noui-repeat-on=true -playlists="SPOTIFY URI" -noui-shuffle=false

Your help is very much appreciated! Thanks for the rad app!

fabiofalci commented 6 years ago
  1. There is no way to save the password. There are workarounds, depending on how much do you trust your computer. I, for instance, have a script like this:
#!/bin/sh
SCONSIFY_PASSWORD=<password> ~/bin/sconsify 

And another

#!/bin/sh
SCONSIFY_PASSWORD=<password> ~/bin/sconsify \
        -ui=false \
        -noui-silent=true \
        -playlists=Beatles 

Where it says <password>, it has got my plain text password. Of course, the files are protected so that only my user can read/execute them. But then when executing, your password will be exposed in the file /proc/<pid>/environ.

Sconsify won't ask the password as SCONSIFY_PASSWORD is present.

The first one I call _sconsify, the second one I call _sconsify_no_ui.

  1. Spotify issues the tokens, and they are valid for 60 min. No way around that. One option is to change the auth mechanism, but that would involve us creating a server for sconsify, then Spotify could issue token and refresh tokens.

Just to remember, the access token is necessary only for loading the playlists and when searching. So if you load sconsify in the morning, and don't search anything, you can use for the whole day, just don't exit sconsify.

  1. Look at my second script that is what -playlists=Beatles is supposed to do. Unfortunately just realised that is not working. Probably when moving the the web-api, we forgot to implement that filter. I'll try to fix that.
feirsom commented 6 years ago

Thanks! Regarding the Tokens, this thread seems to say there is a workaround... no? https://github.com/p2/OAuth2/commit/3f8b24bfd0bf3237f0f46e12fb0980d04f08c6e5

feirsom commented 6 years ago

I'm also looking at the Spotify Developer site: https://developer.spotify.com/web-api/authorization-guide/

see: 7. Requesting access token from refresh token

I'm curious if retrieving a new token could be automated in the script?

feirsom commented 6 years ago

This also seems promising: https://www.npmjs.com/package/passport-spotify

Please advise

fabiofalci commented 6 years ago

Playlist filter is working in the latest release.

No easy solution for saving the password or token expiration. Closing.