From b6340790ca05706d2088c552e90e8b4f7125f3aa Mon Sep 17 00:00:00 2001 From: Raphael <41505593+c0ball@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:50:10 +0200 Subject: [PATCH] Print duplicates that occurred while syncing (#64) --- src/spotify_to_tidal/sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/spotify_to_tidal/sync.py b/src/spotify_to_tidal/sync.py index 5cd3e52..5a4ce0c 100755 --- a/src/spotify_to_tidal/sync.py +++ b/src/spotify_to_tidal/sync.py @@ -224,12 +224,18 @@ def get_tracks_for_new_tidal_playlist(spotify_tracks: Sequence[t_spotify.Spotify ''' gets list of corresponding tidal track ids for each spotify track, ignoring duplicates ''' output = [] seen_tracks = set() + for spotify_track in spotify_tracks: if not spotify_track['id']: continue tidal_id = track_match_cache.get(spotify_track['id']) - if tidal_id and not tidal_id in seen_tracks: - output.append(tidal_id) - seen_tracks.add(tidal_id) + if tidal_id: + if tidal_id in seen_tracks: + track_name = spotify_track['name'] + artist_names = ', '.join([artist['name'] for artist in spotify_track['artists']]) + print(f'Duplicate found: Track "{track_name}" by {artist_names} will be ignored') + else: + output.append(tidal_id) + seen_tracks.add(tidal_id) return output async def sync_playlist(spotify_session: spotipy.Spotify, tidal_session: tidalapi.Session, spotify_playlist, tidal_playlist: tidalapi.Playlist | None, config):