Add clickable watch links to streaming provider badges

Build a provider registry mapping TMDB provider IDs to search URL
templates. `generateProviderUrl()` resolves a URL for a given provider
and title name using URL-encoded search queries. `readAvailability()`
now accepts the title name and attaches `watchUrl` to each offer.

Provider badges with a resolved URL render as `<a>` links opening in a
new tab; tooltip copy switches from the provider name to "Watch on
{name}". Badges without a known URL remain non-interactive as before.
This commit is contained in:
2026-03-05 20:35:59 -05:00
parent 926ddfef34
commit cd4b2908d8
4 changed files with 145 additions and 5 deletions
@@ -19,13 +19,25 @@ const offerLabels: Record<string, string> = {
function ProviderBadge({
name,
logoPath,
watchUrl,
}: {
name: string;
logoPath: string | null;
watchUrl: string | null;
}) {
return (
<Tooltip>
<TooltipTrigger className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-lg border border-border/30 bg-card motion-safe:transition-transform motion-safe:hover:scale-105">
<TooltipTrigger
{...(watchUrl
? {
render: (
// biome-ignore lint/a11y/useAnchorContent: content is provided conditionally below
<a href={watchUrl} target="_blank" rel="noopener noreferrer" />
),
}
: {})}
className={`flex h-10 w-10 items-center justify-center overflow-hidden rounded-lg border border-border/30 bg-card motion-safe:transition-transform motion-safe:hover:scale-105${watchUrl ? "" : " cursor-default"}`}
>
{logoPath ? (
<Image
src={logoPath}
@@ -41,7 +53,7 @@ function ProviderBadge({
)}
</TooltipTrigger>
<TooltipContent className="bg-popover px-2 py-1 text-[10px] font-medium text-popover-foreground shadow-md [&>:last-child]:bg-popover [&>:last-child]:fill-popover">
{name}
{watchUrl ? `Watch on ${name}` : name}
</TooltipContent>
</Tooltip>
);
@@ -77,6 +89,7 @@ export function TitleAvailability({
key={offer.providerId}
name={offer.providerName}
logoPath={offer.logoPath}
watchUrl={offer.watchUrl}
/>
))}
</div>