From ef886644a62b66593010235daf96b99807692e6d Mon Sep 17 00:00:00 2001 From: WonderAliceUwU Date: Wed, 8 Jul 2026 01:34:31 +0200 Subject: [PATCH] feature: add actors --- server/lib/services.ts | 43 +++- shared/contracts.ts | 8 + src/App.tsx | 502 ++++++++++++++++++++++------------------- src/index.css | 113 +++++++++- 4 files changed, 431 insertions(+), 235 deletions(-) diff --git a/server/lib/services.ts b/server/lib/services.ts index 48b4be7..5d15400 100644 --- a/server/lib/services.ts +++ b/server/lib/services.ts @@ -14,7 +14,8 @@ import type { TitleDetailsEpisode, TitleDetailsRequest, TitleDetailsResponse, - TitleDetailsSeason + TitleDetailsSeason, + TitleDetailsCastMember } from '../../shared/contracts.js'; const TMDB_IMAGE = 'https://image.tmdb.org/t/p'; @@ -458,6 +459,7 @@ export async function getTitleDetails( const effectiveBackdropUrl = backdropUrl || resolveBackdrop(seriesItem || item, card); if (!isSeries) { + const movieDetails = tmdbId ? await getTmdbMovieSummary(config, tmdbId) : null; return { id: card.id, tmdbId, @@ -472,7 +474,8 @@ export async function getTitleDetails( backdropUrl: effectiveBackdropUrl, logoUrl: logoUrl || card.logoUrl, seasons: [], - episodes: [] + episodes: [], + cast: buildTitleCast(movieDetails, 'movie') }; } @@ -527,10 +530,42 @@ export async function getTitleDetails( logoUrl: logoUrl || card.logoUrl, selectedSeasonId: selectedSeason?.id, seasons, - episodes + episodes, + cast: buildTitleCast(tmdbSeries, 'series') }; } +function buildTitleCast( + tmdbPayload: Record | null, + mediaType: 'movie' | 'series' +): TitleDetailsCastMember[] { + const creditsKey = mediaType === 'series' ? 'aggregate_credits' : 'credits'; + const castEntries = asArray(asRecord(tmdbPayload?.[creditsKey])?.cast) + .map((entry) => asRecord(entry)) + .slice(0, 20); + + return castEntries.map((entry) => ({ + id: String(entry.id || ''), + name: String(entry.name || ''), + role: String( + entry.character + || asArray(entry.roles).map((role) => String(asRecord(role).character || '')).find(Boolean) + || entry.known_for_department + || '' + ), + imageUrl: typeof entry.profile_path === 'string' && entry.profile_path + ? `${TMDB_IMAGE}/w342${entry.profile_path}` + : '' + })).filter((member) => Boolean(member.id && member.name)); +} + +async function getTmdbMovieSummary(config: AppConfig, tmdbId: number): Promise | null> { + return tmdbFetch( + config, + `/movie/${tmdbId}?append_to_response=credits,images&language=${encodeURIComponent(config.preferences.language)}` + ); +} + async function enrichDownloadItem( config: AppConfig, item: DownloadItem, @@ -789,7 +824,7 @@ async function getPreferredTitleLogo( async function getTmdbSeriesSummary(config: AppConfig, tmdbId: number): Promise | null> { return tmdbFetch( config, - `/tv/${tmdbId}?append_to_response=external_ids&language=${encodeURIComponent(config.preferences.language)}` + `/tv/${tmdbId}?append_to_response=external_ids,aggregate_credits&language=${encodeURIComponent(config.preferences.language)}` ); } diff --git a/shared/contracts.ts b/shared/contracts.ts index 14f946c..023e0ff 100644 --- a/shared/contracts.ts +++ b/shared/contracts.ts @@ -142,6 +142,13 @@ export interface TitleDetailsSeason { downloadLabel?: string; } +export interface TitleDetailsCastMember { + id: string; + name: string; + role: string; + imageUrl: string; +} + export interface TitleDetailsResponse { id: string; tmdbId?: number; @@ -159,6 +166,7 @@ export interface TitleDetailsResponse { selectedSeasonId?: string; seasons: TitleDetailsSeason[]; episodes: TitleDetailsEpisode[]; + cast: TitleDetailsCastMember[]; } export interface DownloadItem { diff --git a/src/App.tsx b/src/App.tsx index 6b30c0d..96e1547 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,6 +20,7 @@ import { type MediaCard, type SelectOption, type ServiceOptionsResponse, + type TitleDetailsCastMember, type TitleDetailsEpisode, type TitleDetailsResponse, } from '../shared/contracts' @@ -1319,6 +1320,7 @@ function TitleDetailsModal(props: { || (canRequest && !details?.sonarrSeriesId && typeof activeSeasonNumber === 'number') ) const canDeleteSeasonAction = Boolean(activeSeasonMeta?.canDelete) + const shouldShowDownloadSeasonAction = canDownloadSeasonAction && !canDeleteSeasonAction useEffect(() => { if (!details || details.mediaType !== 'series') { @@ -1518,258 +1520,286 @@ function TitleDetailsModal(props: {
- {detailsError ?

{detailsError}

: null} - {playerTarget && jellyfinPlayerUrl ? null : ( -
-
- {logoUrl ? ( - {displayTitle} - ) : ( -

{displayTitle}

- )} -
-
-

- {isOverviewExpanded ? displayOverview : truncatedOverview} - {shouldShowOverviewToggle ? ( - <> - {' '} - - - ) : null} -

-
- {canPlay ? ( - - ) : canRequest ? ( - - ) : null} +
+ {detailsError ?

{detailsError}

: null} + {playerTarget && jellyfinPlayerUrl ? null : ( +
+
+ {logoUrl ? ( + {displayTitle} + ) : ( +

{displayTitle}

+ )}
-
- {displayYear ?

{displayYear}

: null} -
- )} - {details?.mediaType === 'series' ? ( -
-
-
- {hasPreviousSeason ? ( - + ) : null} - + {displayYear ?

{displayYear}

: null} +
+ )} + {details?.mediaType === 'series' ? ( +
+
+
+ {hasPreviousSeason ? ( + + ) + ) : null} + {canDeleteSeasonAction ? ( + + ) : null} + {hasNextSeason ? ( +
+
+
+ {episodeScrollState.canScrollLeft ? ( + ) : null} +
+
+ {formatEpisodeMeta(episode.subtitle)} +
+
+ ))} +
-
- {episodeScrollState.canScrollLeft ? ( - - ) : null} -
-
- {formatEpisodeMeta(episode.subtitle)} -
- + ) : null} + {details?.cast.length && details.mediaType === 'movie' ? ( +
+
+

Cast & Crew

+
+
+ {details.cast.map((member) => ( + ))}
- - ) : null} + ) : null} + + {details?.cast.length && details.mediaType === 'series' && !(playerTarget && jellyfinPlayerUrl) ? ( +
+
+
+

Cast & Crew

+
+
+ {details.cast.map((member) => ( + + ))} +
+
+
+ ) : null} @@ -1790,6 +1820,20 @@ function captureOriginRect(element: HTMLElement): ModalOriginRect { } } +function CastCard(props: { member: TitleDetailsCastMember }) { + return ( +
+
+ {props.member.imageUrl ? {props.member.name} :
{props.member.name.slice(0, 1).toUpperCase()}
} +
+
+ {props.member.name} + {props.member.role ? {props.member.role} : null} +
+
+ ) +} + function PlayGlyph() { return (