30 lines
831 B
TypeScript
30 lines
831 B
TypeScript
import { Sort } from '@/data/parsers';
|
|
|
|
type Options = { query: string; sort: Sort; imdbID: string; type?: 'movie' | 'tv' };
|
|
|
|
const queryFn = ({ query, sort, imdbID, type, key }: Options & { key: keyof typeof providers }) =>
|
|
fetch(`/api/torrents?key=${key}&query=${query}&sort=${sort}&imdbID=${imdbID}&type=${type ?? ''}`).then((response) =>
|
|
response.json()
|
|
);
|
|
|
|
export const providers = {
|
|
yts: {
|
|
label: 'YTS',
|
|
key: 'yts',
|
|
queryFn: (options: Options) => queryFn({ ...options, key: 'yts' }),
|
|
sortable: false
|
|
},
|
|
tpb: {
|
|
label: 'The Pirate Bay',
|
|
key: 'tpb',
|
|
queryFn: (options: Options) => queryFn({ ...options, key: 'tpb' }),
|
|
sortable: true
|
|
},
|
|
tlk: {
|
|
label: 'Toloka',
|
|
key: 'tlk',
|
|
queryFn: (options: Options) => queryFn({ ...options, key: 'tlk' }),
|
|
sortable: true
|
|
}
|
|
};
|