Files
movie-advisor/components/Preview/components/Torrents/useUnplayable.ts
T
nerandClaude Opus 4.8 ecc57ff135 feat(player): external subtitles via OpenSubtitles
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>
2026-08-08 13:17:12 +03:00

31 lines
808 B
TypeScript

import { useAtom } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
const unplayableAtom = atomWithStorage<Record<string, string>>('unplayable-torrents', {}, undefined, {
unstable_getOnInit: true
});
const normalize = (hash?: string) => hash?.toLowerCase();
const useUnplayable = () => {
const [unplayable, setUnplayable] = useAtom(unplayableAtom);
const reasonFor = (hash?: string) => {
const key = normalize(hash);
return key ? unplayable[key] : undefined;
};
const markUnplayable = (hash?: string, reason?: string) => {
const key = normalize(hash);
if (!key || !reason) return;
setUnplayable((current) => (current[key] === reason ? current : { ...current, [key]: reason }));
};
return { reasonFor, markUnplayable };
};
export default useUnplayable;