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

Add users saved tracks #9

Merged
merged 6 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ tap-spotify --about
Before using `tap-spotify`, you will need to create an [app](https://developer.spotify.com/documentation/web-api/concepts/apps) from your [Spotify developer dashboard](https://developer.spotify.com/dashboard). We recommend restricting your use of this app to `tap-spotify` only. Provide an name, description and a redirect URI of `https://alecchen.dev/spotify-refresh-token` (explained below).

#### Get a Refresh Token
Use [this web app](https://alecchen.dev/spotify-refresh-token?scope=user-top-read) made by [Alec Chen](https://alecchen.dev/) to get a refresh token with your Spotify app credentials:
Use [this web app](https://alecchen.dev/spotify-refresh-token?scope=user-top-read&scope=user-library-read) made by [Alec Chen](https://alecchen.dev/) to get a refresh token with your Spotify app credentials:
- Provide your app client ID and secret in the appropriate fields
- Click 'Submit' and follow the Spotify login flow
- Copy the refresh token

The following token scopes are required (and are pre-selected for you when following the above web app link):
THe following token scopes are required (and are pre-selected for you when following the above web app link):
- [`user-top-read`](https://developer.spotify.com/documentation/web-api/concepts/scopes#user-top-read)
- [`user-library-read`](https://developer.spotify.com/documentation/web-api/concepts/scopes#user-library-read)

If a required scope is not set, `tap-spotify` will encounter a `403 Forbidden` response from the Spotify Web API and fail. You must set all required scopes.

Expand Down
11 changes: 11 additions & 0 deletions tap_spotify/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,14 @@ class GlobalViralTracksDailyStream(_PlaylistTracksStream):
name = "global_viral_tracks_daily_stream"
path = "/playlists/37i9dQZEVXbLiRSasKsNU9"
primary_keys = ["rank", "synced_at"]


class UserSavedTracksStream(_SyncedAtStream, SpotifyStream):
"""Define user saved tracks stream."""

name = "user_saved_track_stream"
path = "/me/tracks"
primary_keys = ["id", "synced_at"]
limit = 50
schema = TrackObject.extend_with(SyncedAt).schema
records_jsonpath = "$.items[*].track"
1 change: 1 addition & 0 deletions tap_spotify/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
streams.GlobalTopTracksDailyStream,
streams.GlobalTopTracksWeeklyStream,
streams.GlobalViralTracksDailyStream,
streams.UserSavedTracksStream,
]


Expand Down