Skip to content

Commit

Permalink
Filter out tracks which don't have valid album metadata
Browse files Browse the repository at this point in the history
Apply a final sanity filter to tracklist to validate assumption in matching
algorithm that the album has certain fields available.

In most situations this filter is not necessary, but occasionally we do
seem to encounter tracks that have no album metadata
  • Loading branch information
timrae committed Oct 13, 2024
1 parent 4fb702d commit 4d7c3b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/spotify_to_tidal/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def _get_tracks_from_spotify_playlist(offset: int, playlist_id: str):
print(f"Loading tracks from Spotify playlist '{spotify_playlist['name']}'")
items = await repeat_on_request_error( _fetch_all_from_spotify_in_chunks, lambda offset: _get_tracks_from_spotify_playlist(offset=offset, playlist_id=spotify_playlist["id"]))
track_filter = lambda item: item.get('type', 'track') == 'track' # type may be 'episode' also
return list(filter(track_filter, items))
sanity_filter = lambda item: 'album' in item and 'name' in item['album'] and 'artists' in item['album'] and len(item['album']['artists']) > 0
return list(filter(sanity_filter, filter(track_filter, items)))

def populate_track_match_cache(spotify_tracks_: Sequence[t_spotify.SpotifyTrack], tidal_tracks_: Sequence[tidalapi.Track]):
""" Populate the track match cache with all the existing tracks in Tidal playlist corresponding to Spotify playlist """
Expand Down

0 comments on commit 4d7c3b0

Please sign in to comment.