similar artist duplicate fix

pull/64/head
Broque Thomas 6 months ago
parent 5ffce6bb59
commit 208b233497

@ -3829,9 +3829,20 @@ def get_similar_artists_stream(artist_name):
yield f"data: {json.dumps({'error': 'Spotify not authenticated'})}\n\n"
return
# Get the searched artist's Spotify ID to exclude them
searched_artist_id = None
try:
searched_results = spotify_client.search_artists(artist_name, limit=1)
if searched_results and len(searched_results) > 0:
searched_artist_id = searched_results[0].id
print(f"🎯 Searched artist Spotify ID: {searched_artist_id}")
except Exception as e:
print(f"⚠️ Could not get searched artist ID: {e}")
# Match each artist to Spotify one by one and stream results
max_artists = 20
matched_count = 0
seen_artist_ids = set() # Track seen artist IDs to prevent duplicates
for artist_name_to_match in similar_artist_names[:max_artists]:
try:
@ -3843,6 +3854,18 @@ def get_similar_artists_stream(artist_name):
if results and len(results) > 0:
spotify_artist = results[0]
# Skip if this is the searched artist
if spotify_artist.id == searched_artist_id:
print(f"⏭️ Skipping searched artist: {spotify_artist.name}")
continue
# Skip if we've already seen this artist ID (deduplication)
if spotify_artist.id in seen_artist_ids:
print(f"⏭️ Skipping duplicate artist: {spotify_artist.name}")
continue
seen_artist_ids.add(spotify_artist.id)
artist_data = {
'id': spotify_artist.id,
'name': spotify_artist.name,
@ -3946,9 +3969,20 @@ def get_similar_artists(artist_name):
"error": "Spotify not authenticated"
}), 401
# Get the searched artist's Spotify ID to exclude them
searched_artist_id = None
try:
searched_results = spotify_client.search_artists(artist_name, limit=1)
if searched_results and len(searched_results) > 0:
searched_artist_id = searched_results[0].id
print(f"🎯 Searched artist Spotify ID: {searched_artist_id}")
except Exception as e:
print(f"⚠️ Could not get searched artist ID: {e}")
# Match each artist to Spotify (limit to first 20 for performance)
matched_artists = []
max_artists = 20
seen_artist_ids = set() # Track seen artist IDs to prevent duplicates
for artist_name_to_match in similar_artist_names[:max_artists]:
try:
@ -3960,6 +3994,18 @@ def get_similar_artists(artist_name):
if results and len(results) > 0:
spotify_artist = results[0]
# Skip if this is the searched artist
if spotify_artist.id == searched_artist_id:
print(f"⏭️ Skipping searched artist: {spotify_artist.name}")
continue
# Skip if we've already seen this artist ID (deduplication)
if spotify_artist.id in seen_artist_ids:
print(f"⏭️ Skipping duplicate artist: {spotify_artist.name}")
continue
seen_artist_ids.add(spotify_artist.id)
matched_artists.append({
'id': spotify_artist.id,
'name': spotify_artist.name,

@ -16635,17 +16635,13 @@ async function createArtistAlbumVirtualPlaylist(album, albumType) {
throw new Error('No tracks found for this album');
}
console.log(`✅ Loaded ${data.tracks.length} tracks`);
console.log(`📊 [DEBUG] Backend album data:`, data.album);
console.log(`📊 [DEBUG] Album name from backend:`, data.album?.name);
console.log(`📊 [DEBUG] Original album param:`, album);
console.log(`✅ Loaded ${data.tracks.length} tracks for ${data.album.name}`);
// Use album data from API response (has complete data including images array)
const fullAlbumData = data.album;
// Format playlist name with artist and album info
const playlistName = `[${artist.name}] ${fullAlbumData.name}`;
console.log(`📊 [DEBUG] Playlist name created:`, playlistName);
// Open download missing tracks modal with formatted tracks
// Pass false for showLoadingOverlay since we already have one from handleArtistAlbumClick

Loading…
Cancel
Save