Print duplicates that occurred while syncing (#64)

This commit is contained in:
Raphael
2024-06-09 10:50:10 +02:00
committed by GitHub
parent 8692624a8c
commit b6340790ca

View File

@@ -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 ''' ''' gets list of corresponding tidal track ids for each spotify track, ignoring duplicates '''
output = [] output = []
seen_tracks = set() seen_tracks = set()
for spotify_track in spotify_tracks: for spotify_track in spotify_tracks:
if not spotify_track['id']: continue if not spotify_track['id']: continue
tidal_id = track_match_cache.get(spotify_track['id']) tidal_id = track_match_cache.get(spotify_track['id'])
if tidal_id and not tidal_id in seen_tracks: if tidal_id:
output.append(tidal_id) if tidal_id in seen_tracks:
seen_tracks.add(tidal_id) 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 return output
async def sync_playlist(spotify_session: spotipy.Spotify, tidal_session: tidalapi.Session, spotify_playlist, tidal_playlist: tidalapi.Playlist | None, config): async def sync_playlist(spotify_session: spotipy.Spotify, tidal_session: tidalapi.Session, spotify_playlist, tidal_playlist: tidalapi.Playlist | None, config):