fix: torrent size
This commit is contained in:
1 parent
8d7e2df869
commit
c6d306cb7b
22 files changed
+1638
-300
No files matched your search
@@ -0,0 +1,20 @@
|
||||
'use client';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
|
||||
import usePopular from './usePopular';
|
||||
|
||||
export default function Container() {
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = usePopular();
|
||||
|
||||
return (
|
||||
<>
|
||||
<List pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
Nothing was found
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { popularMovies } from '@/lib/api';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
export default async function Popular() {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['popular'],
|
||||
queryFn: () => popularMovies({}),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
||||
@@ -0,0 +1,23 @@
|
||||
'use client';
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import { popularMovies } from '@/lib/api';
|
||||
|
||||
const usePopular = () => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['popular'],
|
||||
queryFn: ({ pageParam }) => {
|
||||
return popularMovies({ page: pageParam as string });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
if (page === total_pages) return undefined;
|
||||
|
||||
return `${page + 1}`;
|
||||
},
|
||||
initialPageParam: '1'
|
||||
});
|
||||
};
|
||||
|
||||
export default usePopular;
|
||||
@@ -0,0 +1,32 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
|
||||
import useSimilar from './useSimilar';
|
||||
|
||||
export default function Container() {
|
||||
const params = useSearchParams();
|
||||
|
||||
const title = params.get('title');
|
||||
const movieId = params.get('movieId') || undefined;
|
||||
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = useSimilar({ movieId });
|
||||
|
||||
return (
|
||||
<>
|
||||
{Boolean(title) && (
|
||||
<span className='inline-flex w-full h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground mb-2'>
|
||||
Similar: {decodeURIComponent(title || '')}
|
||||
</span>
|
||||
)}
|
||||
<List pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
Nothing was found
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { similarMovies } from '@/lib/api';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
export default async function Similar({ searchParams }: { searchParams: Record<string, string> }) {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { movieId } = searchParams || {};
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['similar', movieId],
|
||||
queryFn: () => similarMovies({ movieId }),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
||||
@@ -0,0 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import { similarMovies } from '@/lib/api';
|
||||
|
||||
const useSimilar = ({ movieId }: { movieId?: string }) => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['similar', movieId],
|
||||
enabled: Boolean(movieId),
|
||||
queryFn: ({ pageParam }) => {
|
||||
return similarMovies({ page: pageParam as string, movieId });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
if (page === total_pages) return undefined;
|
||||
|
||||
return `${page + 1}`;
|
||||
},
|
||||
initialPageParam: '1'
|
||||
});
|
||||
};
|
||||
|
||||
export default useSimilar;
|
||||
@@ -0,0 +1,32 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
|
||||
import useStarring from './useStarring';
|
||||
|
||||
export default function Container() {
|
||||
const params = useSearchParams();
|
||||
|
||||
const title = params.get('title');
|
||||
const actorId = params.get('actorId') || undefined;
|
||||
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = useStarring({ actorId });
|
||||
|
||||
return (
|
||||
<>
|
||||
{Boolean(title) && (
|
||||
<span className='inline-flex w-full h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground mb-2'>
|
||||
Starring: {decodeURIComponent(title || '')}
|
||||
</span>
|
||||
)}
|
||||
<List pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
Nothing was found
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { topMovies } from '@/lib/api';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
export default async function Starring({ searchParams }: { searchParams: Record<string, string> }) {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { actorId } = searchParams || {};
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['starring', actorId],
|
||||
queryFn: () => topMovies({ starring: actorId }),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
||||
@@ -0,0 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import { topMovies } from '@/lib/api';
|
||||
|
||||
const useStarring = ({ actorId }: { actorId?: string }) => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['starring', actorId],
|
||||
enabled: Boolean(actorId),
|
||||
queryFn: ({ pageParam }) => {
|
||||
return topMovies({ page: pageParam as string, starring: actorId });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
if (page === total_pages) return undefined;
|
||||
|
||||
return `${page + 1}`;
|
||||
},
|
||||
initialPageParam: '1'
|
||||
});
|
||||
};
|
||||
|
||||
export default useStarring;
|
||||
@@ -1,27 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
|
||||
import useTop from './useTop';
|
||||
|
||||
export default function Container() {
|
||||
const params = useSearchParams();
|
||||
|
||||
const starring = params.get('starring')!;
|
||||
const similar = params.get('similar')!;
|
||||
const title = params.get('title');
|
||||
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = useTop({ starring, similar });
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = useTop();
|
||||
|
||||
return (
|
||||
<>
|
||||
{Boolean(title && (starring || similar)) && (
|
||||
<span className='inline-flex w-full h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground mb-2'>
|
||||
{starring ? 'Starring' : 'Similar'}: {decodeURIComponent(title || '')}
|
||||
</span>
|
||||
)}
|
||||
<List pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { similarMovies, topMovies } from '@/lib/api';
|
||||
import { topMovies } from '@/lib/api';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
export default async function Top({ searchParams }: { searchParams: Record<string, string> }) {
|
||||
export default async function Top() {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { starring, similar } = searchParams || {};
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['top', starring, similar],
|
||||
queryFn: () => (similar ? similarMovies({ movieId: similar }) : topMovies({ starring })),
|
||||
queryKey: ['top'],
|
||||
queryFn: () => topMovies({}),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import { similarMovies, topMovies } from '@/lib/api';
|
||||
import { topMovies } from '@/lib/api';
|
||||
|
||||
const useTop = ({ starring, similar }: { starring?: string; similar?: string }) => {
|
||||
const useTop = () => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['top', starring, similar],
|
||||
queryKey: ['top'],
|
||||
queryFn: ({ pageParam }) => {
|
||||
return similar
|
||||
? similarMovies({ page: pageParam as string, movieId: similar })
|
||||
: topMovies({ page: pageParam as string, starring: starring! });
|
||||
return topMovies({ page: pageParam as string });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import '@/styles/index.css';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Movie advisor',
|
||||
description: 'It will help you find a movie for evening'
|
||||
description: 'It is going to help you find a movie for evening'
|
||||
};
|
||||
|
||||
export const viewport: Viewport = {
|
||||
|
||||
@@ -7,17 +7,19 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
|
||||
export default function Navigation() {
|
||||
const path = usePathname();
|
||||
|
||||
return (
|
||||
<Tabs value={path} className='flex-grow mt-2'>
|
||||
<TabsList className='grid w-full grid-cols-3'>
|
||||
<TabsList className='flex w-full'>
|
||||
{[
|
||||
['/', 'Random'],
|
||||
['/top', 'Top'],
|
||||
['/favorites', 'Favorites']
|
||||
].map(([path, label]) => (
|
||||
{ path: '/', title: 'Random' },
|
||||
{ path: '/popular', title: 'Popular' },
|
||||
{ path: '/top', title: 'Top rated' },
|
||||
{ path: '/favorites', title: 'Favorites' }
|
||||
].map(({ path, title }) => (
|
||||
<Link href={path} className='w-full' key={path}>
|
||||
<TabsTrigger className='w-full' value={path}>
|
||||
{label}
|
||||
{title}
|
||||
</TabsTrigger>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function Actions({ onClose, movie }: Props) {
|
||||
<Button
|
||||
className='h-8 grow'
|
||||
onClick={() => {
|
||||
router.push(`/top?similar=${movie.id}&title=${encodeURIComponent(movie.title)}`);
|
||||
router.push(`/similar?movieId=${movie.id}&title=${encodeURIComponent(movie.title)}`);
|
||||
onClose?.();
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -21,9 +21,9 @@ interface Props {
|
||||
|
||||
const variants = {
|
||||
enter: (direction: number) => ({
|
||||
scale: 0.8,
|
||||
opacity: 0,
|
||||
[direction === 0 ? 'y' : 'x']: direction === 0 ? -100 : direction * 300
|
||||
scale: direction === 0 ? 1 : 0.8,
|
||||
opacity: direction === 0 ? 1 : 0,
|
||||
x: direction === 0 ? 0 : direction * 300
|
||||
}),
|
||||
center: { x: 0, opacity: 1, y: 0, scale: 1 },
|
||||
exit: (direction: number) => ({ scale: 0.8, opacity: 1, x: direction * -300 })
|
||||
|
||||
@@ -17,7 +17,7 @@ const container = {
|
||||
hidden: {},
|
||||
visible: {
|
||||
transition: {
|
||||
staggerChildren: 0.15
|
||||
staggerChildren: 0.03
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -44,7 +44,7 @@ const Credits: FC<Props> = ({ movieId, onPersonClick }) => {
|
||||
key={`${actor.id}_${actor.cast_id}`}
|
||||
title={actor.name}
|
||||
onTap={() => {
|
||||
router.push(`/top?starring=${actor.id}&title=${encodeURIComponent(actor.name)}`);
|
||||
router.push(`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`);
|
||||
onPersonClick?.(actor.id.toString());
|
||||
}}
|
||||
className='p-2 rounded-lg border bg-card text-card-foreground self-end max-w-[150px] w-full shrink-0 cursor-pointer transition-shadow hover:shadow-lg'
|
||||
|
||||
@@ -52,7 +52,7 @@ const hostAtom = atomWithStorage<string>('magnet-host', '');
|
||||
const showHostManagerModal = create(({ onResolve, isOpen }) => {
|
||||
const [host, setHost] = useAtom(hostAtom);
|
||||
return (
|
||||
<Modal className='p-3 pt-0 max-w-[200px] m-auto' isOpen={isOpen} onClose={() => onResolve()}>
|
||||
<Modal className='p-3 max-w-[200px] m-auto' isOpen={isOpen} onClose={() => onResolve()}>
|
||||
<Input
|
||||
autoFocus
|
||||
placeholder='Enter host of Elementum'
|
||||
|
||||
+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]!
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Generated
+1349
-241
File diff suppressed because it is too large.
Load diff
+7
-6
@@ -10,10 +10,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-dialog": "^1.0.5",
|
||||
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||
"@radix-ui/react-hover-card": "^1.0.7",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@radix-ui/react-label": "^2.0.2",
|
||||
"@radix-ui/react-menubar": "^1.0.3",
|
||||
"@radix-ui/react-navigation-menu": "^1.1.4",
|
||||
"@radix-ui/react-popover": "^1.0.6",
|
||||
"@radix-ui/react-scroll-area": "^1.0.4",
|
||||
"@radix-ui/react-separator": "^1.0.3",
|
||||
@@ -22,22 +24,21 @@
|
||||
"@radix-ui/react-switch": "^1.0.3",
|
||||
"@radix-ui/react-tabs": "^1.0.4",
|
||||
"@radix-ui/react-toggle": "^1.0.3",
|
||||
"@radix-ui/react-tooltip": "^1.0.6",
|
||||
"@radix-ui/react-tooltip": "^1.0.7",
|
||||
"@tanstack/react-query": "^5.17.3",
|
||||
"axios": "^1.4.0",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"classnames": "^2.3.2",
|
||||
"clsx": "^2.0.0",
|
||||
"cmdk": "^0.2.0",
|
||||
"cmdk": "^0.2.1",
|
||||
"eslint": "8.45.0",
|
||||
"eslint-config-next": "^14.0.4",
|
||||
"eslint-config-next": "^14.1.3",
|
||||
"framer-motion": "^10.16.16",
|
||||
"jotai": "^2.2.2",
|
||||
"js-cookie": "^3.0.5",
|
||||
"lucide-react": "^0.263.0",
|
||||
"next": "^14.0.4",
|
||||
"next": "^14.1.3",
|
||||
"node-html-parser": "^6.1.5",
|
||||
"openai": "^3.3.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-fast-marquee": "^1.6.0",
|
||||
|
||||
Reference in new issue
Block a user