- new tg parser: /imdb-detail/<tt...> when an IMDb id is available (exact title, local seeder/size sort), keyword search as fallback; rows carry full magnets inline so Play works without a second fetch - wire tg into /api/torrents and /api/magnet, TG_HOST env (default https://torrentgalaxy.info) - Galaxy tab in the torrents modal; tabs now share equal space and hidden-scroll on overflow - fix tab drag&drop: reorder on the sanitized order so tabs added later (like Galaxy) can be dragged
30 lines
978 B
TypeScript
30 lines
978 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
import { Sort } from '@/data/parsers';
|
|
import odc from '@/data/parsers/odc';
|
|
import tg from '@/data/parsers/tg';
|
|
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, tg, 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([]);
|
|
}
|
|
}
|