Couple of Discover page tweaks
Some checks failed
Frontend CI / Lint, Format & Type Check (push) Waiting to run
Frontend CI / Tests (push) Waiting to run
Backend CI / Lint (push) Has been cancelled
Backend CI / Tests (push) Has been cancelled

This commit is contained in:
Harvey 2026-04-18 01:24:50 +01:00
parent 28f76c8db3
commit 02c34cbe6f
6 changed files with 52 additions and 35 deletions

View file

@ -972,7 +972,7 @@ class DiscoverHomepageService:
)
items.append(HomeAlbum(
mbid=mbid,
name=r.get("title", r.get("release_group_name", "Unknown")),
name=r.get("release_name", r.get("title", "Unknown")),
artist_name=r.get("artist_credit_name", r.get("artist_name", "")),
artist_mbid=artist_mbids[0] if artist_mbids else None,
listen_count=r.get("listen_count"),

View file

@ -271,7 +271,7 @@ class DiscoverQueueService:
if isinstance(artist_mbids, list) and artist_mbids:
first_artist_mbid = self._mbid.normalize_mbid(artist_mbids[0]) or ""
album_name = release.get("title") or release.get("release_group_name") or "Unknown"
album_name = release.get("release_name") or release.get("title") or "Unknown"
artist_name = release.get("artist_credit_name") or release.get("artist_name") or "Unknown"
items.append(
self._mbid.make_queue_item(

View file

@ -364,7 +364,7 @@ class TestDiscoverQueuePersonalization:
return_value=[
{
"release_group_mbid": "fresh-rg-1",
"title": "Fresh Album",
"release_name": "Fresh Album",
"artist_credit_name": "Fresh Artist",
"artist_mbids": ["fresh-artist-1"],
}

View file

@ -37,6 +37,7 @@
headerLink?: string | null;
headerActions?: Snippet;
hideHeader?: boolean;
showPreview?: boolean;
}
let {
@ -44,7 +45,8 @@
showConnectCard = true,
headerLink = null,
headerActions,
hideHeader = false
hideHeader = false,
showPreview = true
}: Props = $props();
function getGenreHref(genre: HomeGenre): string {
@ -256,7 +258,7 @@
{/if}
</div>
</svelte:element>
{#if item.mbid}
{#if item.mbid && (($integrationStore.lidarr && !item.in_library && !isItemRequested) || showPreview)}
<div class="flex items-center justify-center gap-1 mt-1 pb-1">
{#if $integrationStore.lidarr && !item.in_library && !isItemRequested}
<AlbumRequestButton
@ -266,15 +268,17 @@
artistMbid={item.artist_mbid ?? undefined}
/>
{/if}
<TrackPreviewButton
artist={item.artist_name ?? ''}
track={item.name}
ytConfigured={$integrationStore.youtube_api}
size="sm"
albumId={item.mbid}
coverUrl={item.image_url}
artistId={item.artist_mbid ?? undefined}
/>
{#if showPreview}
<TrackPreviewButton
artist={item.artist_name ?? ''}
track={item.name}
ytConfigured={$integrationStore.youtube_api}
size="sm"
albumId={item.mbid}
coverUrl={item.image_url}
artistId={item.artist_mbid ?? undefined}
/>
{/if}
</div>
{/if}
</div>

View file

@ -2,7 +2,9 @@
import type { WeeklyExplorationTrack, YouTubeQuotaStatus } from '$lib/types';
import { Music2, Disc3 } from 'lucide-svelte';
import { albumHrefOrNull, artistHrefOrNull } from '$lib/utils/entityRoutes';
import YouTubeIcon from './YouTubeIcon.svelte';
import { integrationStore } from '$lib/stores/integration';
import { libraryStore } from '$lib/stores/library';
import AlbumRequestButton from './AlbumRequestButton.svelte';
import TrackPreviewButton from './TrackPreviewButton.svelte';
interface Props {
@ -25,6 +27,8 @@
const albumHref = $derived(albumHrefOrNull(track.release_group_mbid));
const artistHref = $derived(artistHrefOrNull(track.artist_mbid));
const albumMbid = $derived(track.release_group_mbid);
const isRequested = $derived(albumMbid ? libraryStore.isRequested(albumMbid) : false);
function formatDuration(ms: number | null): string {
if (!ms) return '';
@ -34,11 +38,6 @@
return `${min}:${sec.toString().padStart(2, '0')}`;
}
function youtubeSearchUrl(): string {
const q = [track.artist_name, track.title].filter(Boolean).join(' ');
return `https://www.youtube.com/results?search_query=${encodeURIComponent(q)}`;
}
let imgError = $state(false);
</script>
@ -139,6 +138,14 @@
</div>
<div class="mt-auto flex items-center justify-center gap-3 px-2 pb-1 pt-0.5">
{#if albumMbid && $integrationStore.lidarr && !isRequested}
<AlbumRequestButton
mbid={albumMbid}
artistName={track.artist_name}
albumName={track.album_name || track.title}
artistMbid={track.artist_mbid ?? undefined}
/>
{/if}
<TrackPreviewButton
artist={track.artist_name}
track={track.title}
@ -149,16 +156,6 @@
coverUrl={track.cover_url}
artistId={track.artist_mbid ?? undefined}
/>
<div class="tooltip tooltip-bottom" data-tip="Search on YouTube">
<a
href={youtubeSearchUrl()}
target="_blank"
rel="noopener noreferrer"
class="btn btn-circle btn-ghost btn-sm text-base-content/50 hover:text-error"
>
<YouTubeIcon class="h-4 w-4" />
</a>
</div>
</div>
{#if showQuota && quotaInfo}

View file

@ -39,7 +39,13 @@
}
type PreGenreBlock =
| { key: string; kind: 'section'; section: HomeSectionType; link?: string }
| {
key: string;
kind: 'section';
section: HomeSectionType;
link?: string;
showPreview?: boolean;
}
| { key: 'weekly_exploration'; kind: 'weekly'; section: WeeklyExplorationSectionType };
function getPreGenreBlocks(): PreGenreBlock[] {
@ -77,7 +83,8 @@
key: 'your_top_albums',
kind: 'section',
section: homeData.your_top_albums,
link: '/your-top'
link: '/your-top',
showPreview: false
});
}
if (homeData.recently_played && homeData.recently_played.items.length > 0) {
@ -92,7 +99,8 @@
key: 'recently_added',
kind: 'section',
section: homeData.recently_added,
link: '/library/albums'
link: '/library/albums',
showPreview: false
});
}
return blocks;
@ -235,7 +243,11 @@
{#each whatsHotBlocks as block (block.key)}
<div>
{#if block.kind === 'section'}
<HomeSection section={block.section} headerLink={block.link} />
<HomeSection
section={block.section}
headerLink={block.link}
showPreview={block.showPreview}
/>
{:else}
<WeeklyExploration
section={block.section}
@ -257,7 +269,11 @@
{#each forYouBlocks as block (block.key)}
<div>
{#if block.kind === 'section'}
<HomeSection section={block.section} headerLink={block.link} />
<HomeSection
section={block.section}
headerLink={block.link}
showPreview={block.showPreview}
/>
{:else}
<WeeklyExploration
section={block.section}