fix(blacklist): filter tracks per-artist in compilations and album queue
This commit is contained in:
1 parent
6ecd40b703
commit
4a1b2d6ad1
2 files changed
+60
-23
No files matched your search
@@ -20,6 +20,7 @@
|
||||
number: number;
|
||||
title: string;
|
||||
artist?: string;
|
||||
artistId?: number;
|
||||
duration: string;
|
||||
durationSeconds: number;
|
||||
quality?: string;
|
||||
@@ -417,7 +418,8 @@
|
||||
{#each album.tracks as track, trackIndex (`${track.id}-${downloadStateVersion}`)}
|
||||
{@const downloadInfo = getTrackOfflineCacheStatus?.(track.id) ?? { status: 'none' as const, progress: 0 }}
|
||||
{@const isTrackDownloaded = downloadInfo.status === 'ready'}
|
||||
{@const albumArtistBlacklisted = album.artistId ? isArtistBlacklisted(album.artistId) : false}
|
||||
{@const trackArtistId = track.artistId ?? album.artistId}
|
||||
{@const trackBlacklisted = trackArtistId ? isArtistBlacklisted(trackArtistId) : false}
|
||||
<TrackRow
|
||||
trackId={track.id}
|
||||
number={track.number}
|
||||
@@ -426,17 +428,17 @@
|
||||
duration={track.duration}
|
||||
quality={track.quality}
|
||||
isPlaying={activeTrackId === track.id}
|
||||
isBlacklisted={albumArtistBlacklisted}
|
||||
isBlacklisted={trackBlacklisted}
|
||||
downloadStatus={downloadInfo.status}
|
||||
downloadProgress={downloadInfo.progress}
|
||||
hideFavorite={albumArtistBlacklisted}
|
||||
hideDownload={albumArtistBlacklisted}
|
||||
onPlay={albumArtistBlacklisted ? undefined : () => {
|
||||
hideFavorite={trackBlacklisted}
|
||||
hideDownload={trackBlacklisted}
|
||||
onPlay={trackBlacklisted ? undefined : () => {
|
||||
onTrackPlay?.(track);
|
||||
}}
|
||||
onDownload={!albumArtistBlacklisted && onTrackDownload ? () => onTrackDownload(track) : undefined}
|
||||
onRemoveDownload={!albumArtistBlacklisted && onTrackRemoveDownload ? () => onTrackRemoveDownload(track.id) : undefined}
|
||||
menuActions={albumArtistBlacklisted ? {
|
||||
onDownload={!trackBlacklisted && onTrackDownload ? () => onTrackDownload(track) : undefined}
|
||||
onRemoveDownload={!trackBlacklisted && onTrackRemoveDownload ? () => onTrackRemoveDownload(track.id) : undefined}
|
||||
menuActions={trackBlacklisted ? {
|
||||
// Blacklisted: only navigation and info
|
||||
onGoToArtist: album.artistId && onTrackGoToArtist ? () => onTrackGoToArtist(album.artistId!) : undefined,
|
||||
onShowInfo: onTrackShowInfo ? () => onTrackShowInfo(track.id) : undefined
|
||||
|
||||
+50
-15
@@ -42,7 +42,7 @@
|
||||
getCachedPreferences,
|
||||
isAutoplayEnabled
|
||||
} from '$lib/stores/playbackPreferencesStore';
|
||||
import { initBlacklistStore } from '$lib/stores/artistBlacklistStore';
|
||||
import { initBlacklistStore, isBlacklisted as isArtistBlacklisted } from '$lib/stores/artistBlacklistStore';
|
||||
|
||||
// UI state management
|
||||
import {
|
||||
@@ -1255,12 +1255,18 @@
|
||||
? 'Hi-Res'
|
||||
: '-';
|
||||
|
||||
// Build queue from album tracks before playing
|
||||
// Build queue from album tracks before playing (filter blacklisted artists)
|
||||
if (selectedAlbum?.tracks) {
|
||||
console.log('[Album Queue] Building queue from', selectedAlbum.tracks.length, 'album tracks');
|
||||
|
||||
const trackIndex = selectedAlbum.tracks.findIndex(t => t.id === track.id);
|
||||
const queueTracks: BackendQueueTrack[] = selectedAlbum.tracks.map(t => ({
|
||||
// Filter out blacklisted tracks
|
||||
const playableTracks = selectedAlbum.tracks.filter(t => {
|
||||
const artistId = t.artistId ?? selectedAlbum.artistId;
|
||||
return !artistId || !isArtistBlacklisted(artistId);
|
||||
});
|
||||
|
||||
const trackIndex = playableTracks.findIndex(t => t.id === track.id);
|
||||
const queueTracks: BackendQueueTrack[] = playableTracks.map(t => ({
|
||||
id: t.id,
|
||||
title: t.title,
|
||||
artist: t.artist || selectedAlbum?.artist || 'Unknown Artist',
|
||||
@@ -1275,7 +1281,7 @@
|
||||
artist_id: t.artistId ?? selectedAlbum?.artistId
|
||||
}));
|
||||
|
||||
console.log('[Album Queue] Mapped to', queueTracks.length, 'queue tracks, startIndex:', trackIndex);
|
||||
console.log('[Album Queue] Mapped to', queueTracks.length, 'queue tracks (filtered), startIndex:', trackIndex);
|
||||
console.log('[Album Queue] Track IDs:', queueTracks.map(t => t.id));
|
||||
|
||||
// Set the queue starting at the clicked track
|
||||
@@ -1607,18 +1613,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Play all tracks from album (starting from first track)
|
||||
// Play all tracks from album (starting from first non-blacklisted track)
|
||||
async function handlePlayAllAlbum() {
|
||||
if (!selectedAlbum?.tracks?.length) return;
|
||||
const firstTrack = selectedAlbum.tracks[0];
|
||||
await handleAlbumTrackPlay(firstTrack);
|
||||
// Find first non-blacklisted track
|
||||
const firstPlayableTrack = selectedAlbum.tracks.find(t => {
|
||||
const artistId = t.artistId ?? selectedAlbum.artistId;
|
||||
return !artistId || !isArtistBlacklisted(artistId);
|
||||
});
|
||||
if (!firstPlayableTrack) return;
|
||||
await handleAlbumTrackPlay(firstPlayableTrack);
|
||||
}
|
||||
|
||||
// Shuffle play all tracks from album
|
||||
async function handleShuffleAlbum() {
|
||||
if (!selectedAlbum?.tracks?.length) return;
|
||||
|
||||
console.log('[Album Shuffle] Starting shuffle with', selectedAlbum.tracks.length, 'tracks');
|
||||
// Filter out blacklisted tracks
|
||||
const playableTracks = selectedAlbum.tracks.filter(t => {
|
||||
const artistId = t.artistId ?? selectedAlbum.artistId;
|
||||
return !artistId || !isArtistBlacklisted(artistId);
|
||||
});
|
||||
|
||||
if (playableTracks.length === 0) return;
|
||||
|
||||
console.log('[Album Shuffle] Starting shuffle with', playableTracks.length, 'playable tracks');
|
||||
|
||||
// Set shuffle mode first
|
||||
try {
|
||||
@@ -1629,8 +1648,8 @@
|
||||
}
|
||||
|
||||
// Pick a random track to start with
|
||||
const randomIndex = Math.floor(Math.random() * selectedAlbum.tracks.length);
|
||||
const randomTrack = selectedAlbum.tracks[randomIndex];
|
||||
const randomIndex = Math.floor(Math.random() * playableTracks.length);
|
||||
const randomTrack = playableTracks[randomIndex];
|
||||
|
||||
console.log('[Album Shuffle] Starting from random track index:', randomIndex, 'track:', randomTrack.title);
|
||||
|
||||
@@ -1643,10 +1662,18 @@
|
||||
async function handleAddAlbumToQueueNext() {
|
||||
if (!selectedAlbum?.tracks?.length) return;
|
||||
|
||||
// Filter out blacklisted tracks
|
||||
const playableTracks = selectedAlbum.tracks.filter(t => {
|
||||
const artistId = t.artistId ?? selectedAlbum.artistId;
|
||||
return !artistId || !isArtistBlacklisted(artistId);
|
||||
});
|
||||
|
||||
if (playableTracks.length === 0) return;
|
||||
|
||||
const artwork = selectedAlbum.artwork || '';
|
||||
// Add in reverse order so first track ends up right after current
|
||||
for (let i = selectedAlbum.tracks.length - 1; i >= 0; i--) {
|
||||
const t = selectedAlbum.tracks[i];
|
||||
for (let i = playableTracks.length - 1; i >= 0; i--) {
|
||||
const t = playableTracks[i];
|
||||
queueTrackNext({
|
||||
id: t.id,
|
||||
title: t.title,
|
||||
@@ -1662,15 +1689,23 @@
|
||||
artist_id: t.artistId ?? selectedAlbum?.artistId
|
||||
});
|
||||
}
|
||||
showToast(`Playing ${selectedAlbum.tracks.length} tracks next`, 'success');
|
||||
showToast(`Playing ${playableTracks.length} tracks next`, 'success');
|
||||
}
|
||||
|
||||
// Add all album tracks to end of queue
|
||||
async function handleAddAlbumToQueueLater() {
|
||||
if (!selectedAlbum?.tracks?.length) return;
|
||||
|
||||
// Filter out blacklisted tracks
|
||||
const playableTracks = selectedAlbum.tracks.filter(t => {
|
||||
const artistId = t.artistId ?? selectedAlbum.artistId;
|
||||
return !artistId || !isArtistBlacklisted(artistId);
|
||||
});
|
||||
|
||||
if (playableTracks.length === 0) return;
|
||||
|
||||
const artwork = selectedAlbum.artwork || '';
|
||||
const queueTracks: BackendQueueTrack[] = selectedAlbum.tracks.map(t => ({
|
||||
const queueTracks: BackendQueueTrack[] = playableTracks.map(t => ({
|
||||
id: t.id,
|
||||
title: t.title,
|
||||
artist: t.artist || selectedAlbum?.artist || 'Unknown Artist',
|
||||
|
||||
Reference in new issue
Block a user