init: toloka
This commit is contained in:
1 parent
be9a128793
commit
345cf911a4
5 files changed
+48
-60
No files matched your search
@@ -1,7 +1,27 @@
|
||||
import { TLKTorrents, TPBTorrents, YTSTorrents } from '@/api';
|
||||
import { Sort } from '@/api/parsers';
|
||||
|
||||
type Options = { query: string; sort: Sort; imdbID: string };
|
||||
|
||||
const queryFn = ({ query, sort, imdbID, key }: Options & { key: keyof typeof providers }) =>
|
||||
fetch(`/api/torrents?key=${key}&query=${query}&sort=${sort}&imdbID=${imdbID}`).then((response) => response.json());
|
||||
|
||||
export const providers = {
|
||||
yts: { label: 'YTS', key: 'yts', queryFn: YTSTorrents, sortable: false },
|
||||
tpb: { label: 'The Pirate Bay', key: 'tpb', queryFn: TPBTorrents, sortable: true },
|
||||
tlk: { label: 'Toloka', key: 'tlk', queryFn: TLKTorrents, sortable: true }
|
||||
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
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user