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>
36 lines
756 B
TypeScript
36 lines
756 B
TypeScript
import { cache } from 'react';
|
|
import { isServer, QueryClient } from '@tanstack/react-query';
|
|
|
|
const makeQueryClient = () => {
|
|
return new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 3600 * 1000,
|
|
refetchOnReconnect: false,
|
|
refetchOnMount: false,
|
|
refetchOnWindowFocus: false
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
let browserQueryClient: QueryClient | undefined = undefined;
|
|
|
|
const getServerQueryClient = cache(makeQueryClient);
|
|
|
|
const getQueryClient = () => {
|
|
if (isServer) {
|
|
try {
|
|
return getServerQueryClient();
|
|
} catch (_) {
|
|
return makeQueryClient();
|
|
}
|
|
}
|
|
|
|
if (!browserQueryClient) browserQueryClient = makeQueryClient();
|
|
|
|
return browserQueryClient;
|
|
};
|
|
|
|
export default getQueryClient;
|