Couple of Discover page tweaks
This commit is contained in:
@@ -972,7 +972,7 @@ class DiscoverHomepageService:
|
|||||||
)
|
)
|
||||||
items.append(HomeAlbum(
|
items.append(HomeAlbum(
|
||||||
mbid=mbid,
|
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_name=r.get("artist_credit_name", r.get("artist_name", "")),
|
||||||
artist_mbid=artist_mbids[0] if artist_mbids else None,
|
artist_mbid=artist_mbids[0] if artist_mbids else None,
|
||||||
listen_count=r.get("listen_count"),
|
listen_count=r.get("listen_count"),
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ class DiscoverQueueService:
|
|||||||
if isinstance(artist_mbids, list) and artist_mbids:
|
if isinstance(artist_mbids, list) and artist_mbids:
|
||||||
first_artist_mbid = self._mbid.normalize_mbid(artist_mbids[0]) or ""
|
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"
|
artist_name = release.get("artist_credit_name") or release.get("artist_name") or "Unknown"
|
||||||
items.append(
|
items.append(
|
||||||
self._mbid.make_queue_item(
|
self._mbid.make_queue_item(
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ class TestDiscoverQueuePersonalization:
|
|||||||
return_value=[
|
return_value=[
|
||||||
{
|
{
|
||||||
"release_group_mbid": "fresh-rg-1",
|
"release_group_mbid": "fresh-rg-1",
|
||||||
"title": "Fresh Album",
|
"release_name": "Fresh Album",
|
||||||
"artist_credit_name": "Fresh Artist",
|
"artist_credit_name": "Fresh Artist",
|
||||||
"artist_mbids": ["fresh-artist-1"],
|
"artist_mbids": ["fresh-artist-1"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
headerLink?: string | null;
|
headerLink?: string | null;
|
||||||
headerActions?: Snippet;
|
headerActions?: Snippet;
|
||||||
hideHeader?: boolean;
|
hideHeader?: boolean;
|
||||||
|
showPreview?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -44,7 +45,8 @@
|
|||||||
showConnectCard = true,
|
showConnectCard = true,
|
||||||
headerLink = null,
|
headerLink = null,
|
||||||
headerActions,
|
headerActions,
|
||||||
hideHeader = false
|
hideHeader = false,
|
||||||
|
showPreview = true
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
function getGenreHref(genre: HomeGenre): string {
|
function getGenreHref(genre: HomeGenre): string {
|
||||||
@@ -256,7 +258,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</svelte:element>
|
</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">
|
<div class="flex items-center justify-center gap-1 mt-1 pb-1">
|
||||||
{#if $integrationStore.lidarr && !item.in_library && !isItemRequested}
|
{#if $integrationStore.lidarr && !item.in_library && !isItemRequested}
|
||||||
<AlbumRequestButton
|
<AlbumRequestButton
|
||||||
@@ -266,15 +268,17 @@
|
|||||||
artistMbid={item.artist_mbid ?? undefined}
|
artistMbid={item.artist_mbid ?? undefined}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<TrackPreviewButton
|
{#if showPreview}
|
||||||
artist={item.artist_name ?? ''}
|
<TrackPreviewButton
|
||||||
track={item.name}
|
artist={item.artist_name ?? ''}
|
||||||
ytConfigured={$integrationStore.youtube_api}
|
track={item.name}
|
||||||
size="sm"
|
ytConfigured={$integrationStore.youtube_api}
|
||||||
albumId={item.mbid}
|
size="sm"
|
||||||
coverUrl={item.image_url}
|
albumId={item.mbid}
|
||||||
artistId={item.artist_mbid ?? undefined}
|
coverUrl={item.image_url}
|
||||||
/>
|
artistId={item.artist_mbid ?? undefined}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
import type { WeeklyExplorationTrack, YouTubeQuotaStatus } from '$lib/types';
|
import type { WeeklyExplorationTrack, YouTubeQuotaStatus } from '$lib/types';
|
||||||
import { Music2, Disc3 } from 'lucide-svelte';
|
import { Music2, Disc3 } from 'lucide-svelte';
|
||||||
import { albumHrefOrNull, artistHrefOrNull } from '$lib/utils/entityRoutes';
|
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';
|
import TrackPreviewButton from './TrackPreviewButton.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -25,6 +27,8 @@
|
|||||||
|
|
||||||
const albumHref = $derived(albumHrefOrNull(track.release_group_mbid));
|
const albumHref = $derived(albumHrefOrNull(track.release_group_mbid));
|
||||||
const artistHref = $derived(artistHrefOrNull(track.artist_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 {
|
function formatDuration(ms: number | null): string {
|
||||||
if (!ms) return '';
|
if (!ms) return '';
|
||||||
@@ -34,11 +38,6 @@
|
|||||||
return `${min}:${sec.toString().padStart(2, '0')}`;
|
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);
|
let imgError = $state(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -139,6 +138,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-auto flex items-center justify-center gap-3 px-2 pb-1 pt-0.5">
|
<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
|
<TrackPreviewButton
|
||||||
artist={track.artist_name}
|
artist={track.artist_name}
|
||||||
track={track.title}
|
track={track.title}
|
||||||
@@ -149,16 +156,6 @@
|
|||||||
coverUrl={track.cover_url}
|
coverUrl={track.cover_url}
|
||||||
artistId={track.artist_mbid ?? undefined}
|
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>
|
</div>
|
||||||
|
|
||||||
{#if showQuota && quotaInfo}
|
{#if showQuota && quotaInfo}
|
||||||
|
|||||||
@@ -39,7 +39,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PreGenreBlock =
|
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 };
|
| { key: 'weekly_exploration'; kind: 'weekly'; section: WeeklyExplorationSectionType };
|
||||||
|
|
||||||
function getPreGenreBlocks(): PreGenreBlock[] {
|
function getPreGenreBlocks(): PreGenreBlock[] {
|
||||||
@@ -77,7 +83,8 @@
|
|||||||
key: 'your_top_albums',
|
key: 'your_top_albums',
|
||||||
kind: 'section',
|
kind: 'section',
|
||||||
section: homeData.your_top_albums,
|
section: homeData.your_top_albums,
|
||||||
link: '/your-top'
|
link: '/your-top',
|
||||||
|
showPreview: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (homeData.recently_played && homeData.recently_played.items.length > 0) {
|
if (homeData.recently_played && homeData.recently_played.items.length > 0) {
|
||||||
@@ -92,7 +99,8 @@
|
|||||||
key: 'recently_added',
|
key: 'recently_added',
|
||||||
kind: 'section',
|
kind: 'section',
|
||||||
section: homeData.recently_added,
|
section: homeData.recently_added,
|
||||||
link: '/library/albums'
|
link: '/library/albums',
|
||||||
|
showPreview: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
@@ -235,7 +243,11 @@
|
|||||||
{#each whatsHotBlocks as block (block.key)}
|
{#each whatsHotBlocks as block (block.key)}
|
||||||
<div>
|
<div>
|
||||||
{#if block.kind === 'section'}
|
{#if block.kind === 'section'}
|
||||||
<HomeSection section={block.section} headerLink={block.link} />
|
<HomeSection
|
||||||
|
section={block.section}
|
||||||
|
headerLink={block.link}
|
||||||
|
showPreview={block.showPreview}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<WeeklyExploration
|
<WeeklyExploration
|
||||||
section={block.section}
|
section={block.section}
|
||||||
@@ -257,7 +269,11 @@
|
|||||||
{#each forYouBlocks as block (block.key)}
|
{#each forYouBlocks as block (block.key)}
|
||||||
<div>
|
<div>
|
||||||
{#if block.kind === 'section'}
|
{#if block.kind === 'section'}
|
||||||
<HomeSection section={block.section} headerLink={block.link} />
|
<HomeSection
|
||||||
|
section={block.section}
|
||||||
|
headerLink={block.link}
|
||||||
|
showPreview={block.showPreview}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<WeeklyExploration
|
<WeeklyExploration
|
||||||
section={block.section}
|
section={block.section}
|
||||||
|
|||||||
Reference in New Issue
Block a user