Add an OpenSubtitles client, /api/subtitles routes and useSubtitles to fetch subtitles by show/episode/filename, wire them as player tracks alongside embedded ones, and strip hls.js's auto-added tracks. New OPENSUBTITLES_* / SUBTITLE_LANGUAGES env vars (documented in env.example). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
877 B
TypeScript
38 lines
877 B
TypeScript
'use client';
|
|
|
|
import { FC, MouseEvent } from 'react';
|
|
import Link from 'next/link';
|
|
|
|
import { useMutateShowState } from '@/hooks/useShowState';
|
|
|
|
interface Props {
|
|
show: Show;
|
|
href?: string;
|
|
onClick?: () => void;
|
|
}
|
|
|
|
const Handlers: FC<Props> = ({ href, onClick, show }) => {
|
|
const { mutate } = useMutateShowState(show);
|
|
|
|
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
if (!onClick) return;
|
|
|
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
|
|
event.preventDefault();
|
|
onClick();
|
|
};
|
|
|
|
const handlers = {
|
|
onClick: handleClick,
|
|
onDoubleClick: () => mutate({ list: 'favorite', value: true }),
|
|
className: 'absolute left-0 top-0 size-full'
|
|
};
|
|
|
|
if (!href) return <div {...handlers} />;
|
|
|
|
return <Link {...handlers} href={href} prefetch={false} aria-label={show.title} />;
|
|
};
|
|
|
|
export default Handlers;
|