init: toloka

This commit is contained in:
ner committed 2024-10-25 22:00:02 +03:00
1 parent be9a128793
commit 345cf911a4
5 files changed
+48 -60

No files matched your search

+1 -54
View File
@@ -5,11 +5,8 @@ import { cookies } from 'next/headers';
import { createUniqueRandomGenerator } from '@/lib/utils';
import mapMoviesSeriesResponseToShows, { mapMovieSeriesToShow } from './dto/Show';
import pirateBay from './parsers/pirate-bay';
import toloka from './parsers/toloka';
import yts from './parsers/yts';
import http from './Http';
import { Sort } from './parsers';
const session = () => cookies().get('session')?.value;
@@ -238,54 +235,4 @@ export const credits = async ({
});
};
export const trailers = async ({
showId,
showType
}: {
showId: Show['id'];
showType?: Show['type'];
}): Promise<Trailer[]> => {
return http
.get<{ id: number; results: Trailer[] }>(`/${showType}/${showId}/videos`, {
params: {
language: 'en-US'
}
})
.then((data) => data.results);
};
export const YTSTorrents = async ({ query, sort, imdbID }: { imdbID: string; query: string; sort: Sort }) => {
try {
return yts.search({
imdbID,
query,
sort
});
} catch (error) {
return [];
}
};
export const TPBTorrents = async ({ query, sort }: { imdbID: string; query: string; sort: Sort }) => {
try {
return pirateBay.search({
query,
sort
});
} catch (error) {
return [];
}
};
export const TLKTorrents = async ({ query, sort }: { imdbID: string; query: string; sort: Sort }) => {
try {
return toloka.search({
query,
sort
});
} catch (error) {
return [];
}
};
export const fetchTLKMagnet = async (url: string) => toloka.magnet(url);
export const fetchTLKMagnet = async (url: string) => toloka.magnet(url);