fix: torrent size
This commit is contained in:
1 parent
8d7e2df869
commit
c6d306cb7b
22 files changed
+1638
-300
No files matched your search
+14
-2
@@ -29,7 +29,19 @@ export const randomMovies = async ({ filters }: { filters: Partial<Filters> }):
|
||||
.then((data: unknown) => (data as MovieDBResponse).results);
|
||||
};
|
||||
|
||||
export const topMovies = async ({ page, starring }: { page?: string; starring: string }): Promise<MovieDBResponse> => {
|
||||
export const popularMovies = async ({ page }: { page?: string }): Promise<MovieDBResponse> => {
|
||||
return server.get('/discover/movie', {
|
||||
params: {
|
||||
page,
|
||||
sort_by: 'popularity.desc',
|
||||
'vote_count.gte': 0,
|
||||
'vote_average.lte': 10,
|
||||
'vote_average.gte': 0
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const topMovies = async ({ page, starring }: { page?: string; starring?: string }): Promise<MovieDBResponse> => {
|
||||
return server.get('/discover/movie', {
|
||||
params: {
|
||||
page,
|
||||
@@ -48,7 +60,7 @@ export const similarMovies = async ({
|
||||
movieId
|
||||
}: {
|
||||
page?: string;
|
||||
movieId: string;
|
||||
movieId?: string;
|
||||
}): Promise<MovieDBResponse> => {
|
||||
return server.get(`/movie/${movieId}/recommendations`, {
|
||||
params: {
|
||||
|
||||
@@ -30,19 +30,20 @@ export class PirateBay {
|
||||
return this.client.post(`/search/${query}/${page}/${order}/${category}`, null).then(({ data }) => {
|
||||
const html = parse(data);
|
||||
const table = html?.getElementById('searchResult');
|
||||
const rows = table?.querySelectorAll('tr:not(.header)');
|
||||
|
||||
const titles = rows?.map((row) => row.querySelector('td:nth-child(2) a')?.innerText).filter(Boolean);
|
||||
const seeders = rows?.map((row) => row.querySelector('td:nth-child(6)')?.innerText);
|
||||
|
||||
const sizes = rows?.reduce((sizes, row) => {
|
||||
const size = row.querySelector('td:nth-child(5)')?.innerText;
|
||||
|
||||
if (!size) return sizes;
|
||||
|
||||
const titles = table?.querySelectorAll('.vertTh + td > a').map((link) => link.innerText);
|
||||
const seeders = table
|
||||
?.querySelectorAll('td[align="right"]')
|
||||
.filter((_, index) => index % 2 === 0)
|
||||
.map((cell) => cell.innerText);
|
||||
const sizes = table?.querySelectorAll('.detDesc').reduce((sizes, description) => {
|
||||
const list = description.innerText?.split(', ');
|
||||
if (list.length === 1) return sizes;
|
||||
const [, size] = list;
|
||||
sizes.push(size.replace(' ', ' ').replace('Size ', ''));
|
||||
return sizes;
|
||||
}, [] as string[]);
|
||||
|
||||
const magnets = table?.querySelectorAll('a[href^="magnet:"]').map((link) => link.getAttribute('href'));
|
||||
|
||||
return titles.map((title, index) => {
|
||||
@@ -50,8 +51,8 @@ export class PirateBay {
|
||||
title,
|
||||
id: title,
|
||||
size: sizes[index],
|
||||
seeders: parseInt(seeders[index]),
|
||||
magnet: magnets[index]
|
||||
seeders: parseInt(seeders[index]!),
|
||||
magnet: magnets[index]!
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user