Closed moritonal closed 1 year ago
Sounds reasonable, feel free to submit a PR when you get around to it.
Do you think it's possible to make using SpotifyOAuth optional since it involves an extra step?
Library is great, but doesn't support user's liked Songs. This is because it's currently using the Client Credentials Flow. Turns out you can support user's liked songs with only a few extra steps.
I'll outline here and try put together a PR sometime, it just requires a few changes.
- Add
http://localhost
as a redirect URL on Spotify- Swap out
SpotifyClientCredentials
forSpotifyOAuth(client_id=conf['client_id'], client_secret=conf['client_secret'], scope="user-library-read", redirect_uri="http://localhost")
- When you login, it'll open a browser, ask the user to sign in, then you copy the URL back into console
- Make a new func like this:
def getSpotifyLikedTracks(self): results = [] playlists = self.api.current_user_saved_tracks(20) while playlists: for i, playlist in enumerate(playlists['items']): result = build_result(playlist); results.append(result) if playlists['next']: playlists = self.api.next(playlists) else: playlists = None return results
Splitting out
build_results
into:def build_results(tracks, album=None): results = [] for track in tracks: result = build_result(track, album) if result is not None: results.append(result) return results def build_result(track, album=None): if 'track' in track: track = track['track'] album_name = album if album else track['album']['name'] return { 'artist': ' '.join([artist['name'] for artist in track['artists']]), 'name': track['name'], 'album': album_name, 'duration': track['duration_ms']/1000 }
And then have a func somewhere in
main
doing the following:tracks = Spotify().getSpotifyLikedTracks() videoIds = ytmusic.search_songs(tracks) playlist_id = ytmusic.create_playlist("Liked Music", "Liked Music", "PRIVATE", videoIds)
Any idea when you could submit this? I'm having a few issues
Hello friends, any news?
I'm open towards somebody submitting an implementation. The SpotifyOAuth should be optional though and only used where relevant (i.e. for all transfer, liked songs).
hi. I opened the spotify application on my pc (windows), then I selected all the liked songs with the Ctrl + A button and added them to a new playlist.
Library is great, but doesn't support user's liked Songs. This is because it's currently using the Client Credentials Flow. Turns out you can support user's liked songs with only a few extra steps.
I'll outline here and try put together a PR sometime, it just requires a few changes.
http://localhost
as a redirect URL on SpotifySpotifyClientCredentials
forSpotifyOAuth(client_id=conf['client_id'], client_secret=conf['client_secret'], scope="user-library-read", redirect_uri="http://localhost")
Splitting out
build_results
into:And then have a func somewhere in
main
doing the following: