Zibbp / tidal-utils

Convert Spotify playlists to Tidal playlists and more.
GNU General Public License v3.0
24 stars 1 forks source link

Spotify updates #5

Closed Zibbp closed 2 years ago

Zibbp commented 2 years ago

This PR includes a non-backwards compatible update with how the application authenticates with Spotify.

Feature request found in #2.

Changes

Notes

Before this PR, Spotify API access was accomplished using an application id and secret allowing an "anonymous" login. Now logging into Spotify requires an authorization flow granting access to tidal-utils. This allows the application to read what playlists you own or have liked.

The new login method allows tidal-utils to convert any playlist you own or have liked automatically without the need to manually enter playlist IDs. For users who prefer to manually enter playlist IDs, it will still be possible by setting a config option.

Leptopoda commented 2 years ago

The docker compose file should also expose the redirect port

    ports:
      - 28542:28542

I'm currently able to log in to spotify but have problems loading the playlists:

Attaching to tidal-utils
tidal-utils  | time="2022-06-14T07:53:53Z" level=info msg="Tidal access token is valid."
tidal-utils  | time="2022-06-14T07:53:53Z" level=info msg="User mode enabled."
tidal-utils  | time="2022-06-14T07:53:53Z" level=debug msg="Getting playlists for Tidal user :upside_down_face:"
tidal-utils  | time="2022-06-14T07:53:53Z" level=debug msg="Getting https://listen.tidal.com/v1/users/:upside_down_face:/playlists"
tidal-utils exited with code 0

Gonna try to debug it now

EDIT: Seems like it only takes into account public playlists displayed on my profile. As I don't publicly advertise my playlists on my profile usrPlaylists is empty and no playlist is downloaded. As soon as I add a playlist to the profile it starts downloading them.

Also the oauth access requested by the app does only ask for public playlists so the auth token doesn't have the scope to access private playlists.

EDIT2:

https://github.com/zmb3/spotify/blob/c886435b98ac304491c4e993ecd95988b0a86415/playlist.go#L124-L132

reading a bit in the library code it indeed seems to be some scope related issue.

Zibbp commented 2 years ago

I'll take a look at the scopes and see what I can find for private playlists.

Zibbp commented 2 years ago

I've added the ScopePlaylistReadPrivate scope which should allow the playlists to be read now. My private playlists were able to be read before without this scope, so you must have something enabled locking them down even more.

Leptopoda commented 2 years ago

regarding the api scpoe it is working now.

1 is also fixed (closing)

But now the program hangs before showing the tidal login url (when starting fresh withouth a tidal login token)

Zibbp commented 2 years ago

It was working in VS Code's terminal but couldn't get the link either in a different shell. I just pushed a commit that uses the logging package to show the oauth URLs.

Leptopoda commented 2 years ago

works great now. Thanks for taking the time to debug/implement this :)

Zibbp commented 2 years ago

Thanks for testing my changes! I'll merge this and put out a new release soon.