Files
Showy/react_frontend/src/components/entries/CastList.tsx
T
X4Lo a9ff2d089a Store full TMDB data, add rate limiting and stale-entry refresh
Backend
- Route all TMDB requests through a rate limiter (20 req/s, 8 concurrent)
  with 429/5xx retries; stop logging the API key
- Fetch external ids, certification, keywords, videos, watch providers and
  alternative titles in the entry details request
- Shared entry mapper used by create, refresh, season refresh and importer
- New columns on entries, ids, ratings, seasons, episodes and people, with
  an idempotent startup migration (adds missing columns, widens types)
- Fix TV IMDb ids, network country/logo, episode tmdb_id on refresh, and
  genre/network removal on refresh
- Add stale-entries maintenance job (count, start, cancel) and live
  recommendations endpoint

Frontend
- Entry page: certification, tagline, creators, in-app trailer, vote count,
  TV/movie details, network logos, external links, keywords, where to
  watch, and recommendations
- Episode page: directors, writers and guest stars
- Settings: TMDB refresh card with live progress
2026-11-05 11:39:15 +00:00

113 lines
3.3 KiB
TypeScript

import { Link } from "react-router-dom";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { getProfileUrl } from "@/lib/media-utils";
import { ChevronRight } from "lucide-react";
import type { Credit } from "@/types";
interface CastListProps {
credits: Credit[];
entryId?: number;
isTvSeries?: boolean;
/** Limit visible cast cards (default: show all) */
maxItems?: number;
/** Override link for "All Cast & Crew" — if unset, uses /entry/:entryId/cast */
allCastHref?: string;
/** Section heading (default: "Cast") */
title?: string;
}
export function CastList({
credits,
entryId,
isTvSeries,
maxItems,
allCastHref,
title = "Cast",
}: CastListProps) {
let castCredits = credits.filter((c) => c.cast_type === "cast");
const hasMore = maxItems != null && castCredits.length > maxItems;
if (hasMore) {
castCredits = castCredits.slice(0, maxItems);
}
if (castCredits.length === 0) return null;
const allCastLink =
allCastHref || (entryId != null ? `/entry/${entryId}/cast` : null);
return (
<div className="space-y-3">
<div className="flex items-center justify-between">
<h3 className="text-lg font-semibold">{title}</h3>
{allCastLink && (
<Link
to={allCastLink}
className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors"
>
All Cast &amp; Crew
<ChevronRight className="h-4 w-4" />
</Link>
)}
</div>
<ScrollArea className="w-full">
<div className="flex gap-4 pb-4">
{castCredits.map((credit) => (
<CastCard key={credit.id} credit={credit} isTvSeries={isTvSeries} />
))}
</div>
<ScrollBar orientation="horizontal" />
</ScrollArea>
</div>
);
}
function CastCard({
credit,
isTvSeries,
}: {
credit: Credit;
isTvSeries?: boolean;
}) {
const profileUrl = credit.people?.profile_path
? getProfileUrl(credit.people.profile_path)
: undefined;
// For local DB credits, link to /people/:id. For TMDB preview credits (no entry_id), link via tmdb_id.
const personLink = credit.entry_id
? `/people/${credit.people_id}`
: `/people/tmdb/${credit.people?.tmdb_id ?? credit.people_id}`;
return (
<Link
to={personLink}
className="flex w-28 shrink-0 flex-col items-center gap-2 text-center"
>
<Avatar className="h-20 w-20">
<AvatarImage src={profileUrl} alt={credit.people?.name} />
<AvatarFallback className="text-xs">
{credit.people?.name
?.split(" ")
.map((n) => n[0])
.join("")}
</AvatarFallback>
</Avatar>
<div>
<p className="text-xs font-medium leading-tight line-clamp-2">
{credit.people?.name}
</p>
<p className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
{credit.character}
</p>
{isTvSeries &&
credit.episode_count != null &&
credit.episode_count > 0 && (
<p className="text-[10px] text-muted-foreground/70 leading-tight">
{credit.episode_count} ep.
</p>
)}
</div>
</Link>
);
}