- parse Toloka Ukrainian season/episode naming (Сезони 1-10, серій 7 з 8, homoglyphs) into a clean title + episodes field - add series-only sortable S:E column, desktop-only Year column; strip year/source meta from the title cell - filter out torrents with fewer than 5 seeders in the API route - cache Toloka magnets in Redis so each .torrent is downloaded once across serverless instances; append public trackers to magnets (never the passkey-bearing announce URLs from the .torrent) - fix play button hover state while magnet is pending Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
27 lines
804 B
TypeScript
27 lines
804 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
import { Sort } from '@/data/parsers';
|
|
import tlk from '@/data/parsers/tlk';
|
|
import tpb from '@/data/parsers/tpb';
|
|
import yts from '@/data/parsers/yts';
|
|
|
|
const MIN_SEEDERS = 5;
|
|
|
|
export async function GET({ nextUrl: { searchParams } }: NextRequest) {
|
|
const key = searchParams.get('key') as keyof typeof providers;
|
|
|
|
const imdbID = searchParams.get('imdbID') as string;
|
|
const query = searchParams.get('query') as string;
|
|
const sort = searchParams.get('sort') as Sort;
|
|
|
|
const providers = { yts, tpb, tlk };
|
|
|
|
try {
|
|
const torrents = await providers[key].search({ imdbID, query, sort });
|
|
|
|
return NextResponse.json(torrents.filter((torrent) => torrent.seeders >= MIN_SEEDERS));
|
|
} catch (_) {
|
|
return NextResponse.json([]);
|
|
}
|
|
}
|