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>
This commit is contained in:
1 parent
c695697c4f
commit
ecc57ff135
24 files changed
+372
-67
No files matched your search
@@ -13,7 +13,6 @@ import { parseTolokaTitle } from './title';
|
||||
|
||||
const COOKIE_JAR_KEY = 'toloka:cookie-jar';
|
||||
|
||||
// UpstashError messages embed the full command, including cookie values — never log them
|
||||
const redisWarn = (message: string, error: unknown) =>
|
||||
console.warn(message, error instanceof Error ? error.message.split(', command was:')[0] : error);
|
||||
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
import torrentTitle from 'parse-torrent-title';
|
||||
|
||||
// Toloka series naming comes in several shapes, often bilingual with both parentheticals present:
|
||||
// "Офіс (Сезон 1) / The Office (Season 1) (2005) BDRemux"
|
||||
// "Друзі (Сезони 1-10) / Friends (Seasons 1-10) 720p"
|
||||
// "Дім дракона (Сезон 3, серій 7 з 8) / House of the Dragon [2026] WEB-DL"
|
||||
// "Томас і його друзі (1—4 сезони, 88 зі 104) / Thomas the Tank Engine & Friends (Seasons 1-4, 88 of 104)"
|
||||
// "[cс]езон" tolerates the Latin "C" homoglyph some uploaders use
|
||||
const SEASONS = [
|
||||
/\(\s*[cс]езон[а-яіїєґ]*\s*(\d+)(?:\s*[-–—−]\s*(\d+))?([^)]*)\)/i,
|
||||
/\(\s*(\d+)(?:\s*[-–—−]\s*(\d+))?\s*[cс]езон[а-яіїєґ]*([^)]*)\)/i,
|
||||
/\(\s*seasons?\s*(\d+)(?:\s*[-–—−]\s*(\d+))?([^)]*)\)/i
|
||||
];
|
||||
|
||||
// ", Серії 6-7" | ", серій 7 з 8" | ", 85 серій з 106" | ", 88 зі 104" | ", 88 of 104"
|
||||
const EPISODES = /,\s*(?:сері[яїй][^\d)]*)?(\d+)(?:\s*[-–—−]\s*(\d+))?(?:[^\d)]*?\s(?:зі?|of)\s*(\d+))?/i;
|
||||
|
||||
export const parseTolokaTitle = (originalTitle: string) => {
|
||||
@@ -22,7 +15,6 @@ export const parseTolokaTitle = (originalTitle: string) => {
|
||||
.trim();
|
||||
|
||||
const parsed = torrentTitle.parse(cleaned);
|
||||
// a season parenthetical between the two title parts leaves a dangling separator behind
|
||||
const title = parsed.title.replace(/\s*[/|]\s*$/, '');
|
||||
|
||||
if (!seasonMatch) {
|
||||
@@ -33,7 +25,6 @@ export const parseTolokaTitle = (originalTitle: string) => {
|
||||
|
||||
const [, seasonFrom, seasonTo, details] = seasonMatch;
|
||||
const [, from, to, total] = details.match(EPISODES) || [];
|
||||
// a bare number with no range, no total and no "серія" marker is not episode info (e.g. a year)
|
||||
const hasEpisodes = from && (to || total || /сері/i.test(details));
|
||||
|
||||
const season = `S${seasonFrom}${seasonTo ? `-${seasonTo}` : ''}`;
|
||||
|
||||
Reference in new issue
Block a user