Files
movie-advisor/app/api/torrents/route.ts
T
ner 1fd8f0f7e5 feat(torrents): add 0day.community tracker as a torrent provider
Private xbtit tracker (tracker.0day.community): session login via
takelogin.php with cookie jar persisted to Redis, cp1251-decoded
word-AND search scoped to movie/TV categories, magnet built from the
fetched .torrent (download.php requires the name param) + public
trackers. Generalizes /api/magnet to dispatch by provider.
2026-10-25 17:09:51 +02:00

29 lines
938 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { Sort } from '@/data/parsers';
import odc from '@/data/parsers/odc';
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 type = searchParams.get('type') as 'movie' | 'tv' | null;
const providers = { yts, tpb, tlk, odc };
try {
const torrents = await providers[key].search({ imdbID, query, sort, type: type ?? undefined });
return NextResponse.json(torrents.filter((torrent) => torrent.seeders >= MIN_SEEDERS));
} catch (_) {
return NextResponse.json([]);
}
}