This commit is contained in:
Eduard Prigoana 2026-02-23 17:50:35 +00:00
parent 49c054e64a
commit 895cc20d26
2 changed files with 17 additions and 5 deletions

View file

@ -917,15 +917,25 @@ export class LosslessAPI {
const recommendedTracks = [];
const seenTrackIds = new Set(tracks.map((t) => t.id));
const artistsToProcess = artists.slice(0, Math.min(5, artists.length));
// Shuffle artists if refreshing to get different results
let shuffledArtists = artists;
if (options.refresh) {
shuffledArtists = [...artists].sort(() => Math.random() - 0.5);
}
const artistsToProcess = shuffledArtists.slice(0, Math.min(5, shuffledArtists.length));
const artistPromises = artistsToProcess.map(async (artist) => {
try {
console.log(`Fetching tracks for artist: ${artist.name} (ID: ${artist.id})`);
const artistData = await this.getArtist(artist.id, { lightweight: true, skipCache: options.skipCache });
const artistData = await this.getArtist(artist.id, { lightweight: true, skipCache: options.refresh });
if (artistData && artistData.tracks && artistData.tracks.length > 0) {
const newTracks = artistData.tracks.filter((track) => !seenTrackIds.has(track.id)).slice(0, 4);
return newTracks;
const availableTracks = artistData.tracks.filter((track) => !seenTrackIds.has(track.id));
// Shuffle and pick different tracks when refreshing
const shuffled = options.refresh
? availableTracks.sort(() => Math.random() - 0.5)
: availableTracks;
return shuffled.slice(0, 4);
} else {
console.warn(`No tracks found for artist ${artist.name}`);
return [];

View file

@ -2440,7 +2440,9 @@ export class UIRenderer {
}
try {
let recommendedTracks = await this.api.getRecommendedTracksForPlaylist(tracks, 20, forceRefresh);
let recommendedTracks = await this.api.getRecommendedTracksForPlaylist(tracks, 20, {
refresh: forceRefresh,
});
// Filter out blocked tracks
const { contentBlockingSettings } = await import('./storage.js');