feat(torrents): launched state, year-scoped Toloka search, stacked modal backdrops
- replace pin-to-top with persistent launched-once state (filled play/cast icons) - move download/vlc actions into a more-options dropdown when cast is available - scope Toloka search query by show year (no IMDB filter on the tracker) - strip session sid from Toloka download hrefs so cached magnets stay valid - restore row hover, subtle row borders, taller rows; drop table rounding - stacked modal backdrops: :has(~ [data-overlay]) instead of :not(:last-of-type) - only count search in analytics after the query has settled (1s debounce)
This commit is contained in:
1 parent
66776c582f
commit
c52d798221
12 files changed
+179
-92
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
*.log
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
FROM node:22-alpine AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN mkdir -p .git && npm ci
|
||||||
|
|
||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
ARG NEXT_PUBLIC_OPENPANEL_CLIENT_ID
|
||||||
|
ARG NEXT_PUBLIC_OPENPANEL_API_URL
|
||||||
|
ARG NEXT_PUBLIC_TORRENT_PROXY
|
||||||
|
ARG NEXT_PUBLIC_VERCEL_ENV=production
|
||||||
|
ARG NEXT_PUBLIC_VERCEL_URL=watchnext.noisy-silence.duckdns.org
|
||||||
|
ARG NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL=watchnext.noisy-silence.duckdns.org
|
||||||
|
ARG NEXT_PUBLIC_TITLE=Movie Advisor
|
||||||
|
ENV NEXT_PUBLIC_OPENPANEL_CLIENT_ID=$NEXT_PUBLIC_OPENPANEL_CLIENT_ID \
|
||||||
|
NEXT_PUBLIC_OPENPANEL_API_URL=$NEXT_PUBLIC_OPENPANEL_API_URL \
|
||||||
|
NEXT_PUBLIC_TORRENT_PROXY=$NEXT_PUBLIC_TORRENT_PROXY \
|
||||||
|
NEXT_PUBLIC_VERCEL_ENV=$NEXT_PUBLIC_VERCEL_ENV \
|
||||||
|
NEXT_PUBLIC_VERCEL_URL=$NEXT_PUBLIC_VERCEL_URL \
|
||||||
|
NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL=$NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL \
|
||||||
|
NEXT_PUBLIC_TITLE=$NEXT_PUBLIC_TITLE
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:22-alpine AS run
|
||||||
|
WORKDIR /app
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
COPY --from=build /app ./
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["npx", "next", "start", "-H", "0.0.0.0", "-p", "3000"]
|
||||||
@@ -21,9 +21,11 @@ export const showSearchModal = create(({ onResolve }) => {
|
|||||||
const isFetchedRef = useRef(false);
|
const isFetchedRef = useRef(false);
|
||||||
|
|
||||||
const query = useDistinctUntilChanged(title);
|
const query = useDistinctUntilChanged(title);
|
||||||
|
const settledTitle = useDistinctUntilChanged(title, 1000);
|
||||||
|
const settled = title === settledTitle;
|
||||||
|
|
||||||
const movies = useSearch({ query, type: 'movie' });
|
const movies = useSearch({ query, type: 'movie', settled });
|
||||||
const series = useSearch({ query, type: 'tv' });
|
const series = useSearch({ query, type: 'tv', settled });
|
||||||
|
|
||||||
const handleChangeTitle = ({ target: { value } }: ChangeEvent<HTMLInputElement>) => setTitle(value);
|
const handleChangeTitle = ({ target: { value } }: ChangeEvent<HTMLInputElement>) => setTitle(value);
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import useInfiniteList from '@/hooks/useInfiniteList';
|
|||||||
import analytics from '@/lib/analytics';
|
import analytics from '@/lib/analytics';
|
||||||
import useTrackOnce from '@/lib/analytics/useTrackOnce';
|
import useTrackOnce from '@/lib/analytics/useTrackOnce';
|
||||||
|
|
||||||
const useSearch = (props: SearchQueryProps) => {
|
const useSearch = (props: SearchQueryProps & { settled: boolean }) => {
|
||||||
const previousRef = useRef<Show[]>([]);
|
const previousRef = useRef<Show[]>([]);
|
||||||
|
|
||||||
const infiniteQuery = useInfiniteList({ ...searchQuery(props), mode: 'default', list: 'search' });
|
const infiniteQuery = useInfiniteList({ ...searchQuery(props), mode: 'default', list: 'search' });
|
||||||
|
|
||||||
useTrackOnce(
|
useTrackOnce(
|
||||||
analytics.searchPerformed,
|
analytics.searchPerformed,
|
||||||
props.query && infiniteQuery.isFetched ? `${props.type}:${props.query}` : undefined,
|
props.query && props.settled && infiniteQuery.isFetched ? `${props.type}:${props.query}` : undefined,
|
||||||
() => ({ query: props.query, showType: props.type, results: infiniteQuery.shows.length })
|
() => ({ query: props.query, showType: props.type, results: infiniteQuery.shows.length })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+82
-43
@@ -1,16 +1,23 @@
|
|||||||
import { FC, useEffect, useMemo, useState } from 'react';
|
import { FC, useEffect, useMemo, useState } from 'react';
|
||||||
import { Bookmark, Cast, Download, ListVideo, Loader, Magnet, Play, TrafficCone } from 'lucide-react';
|
import { Cast, Download, ListVideo, Loader, Magnet, MoreHorizontal, Play, TrafficCone } from 'lucide-react';
|
||||||
|
|
||||||
import { providers } from '@/components/Preview/components/Torrents/constants';
|
import { providers } from '@/components/Preview/components/Torrents/constants';
|
||||||
import { useCastMagnet, usePrefix } from '@/components/Preview/components/Torrents/hooks/useMagnetHosts';
|
import { useCastMagnet, usePrefix } from '@/components/Preview/components/Torrents/hooks/useMagnetHosts';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import ButtonsGroup from '@/components/ui/buttons-group';
|
import ButtonsGroup from '@/components/ui/buttons-group';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger
|
||||||
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { Quality } from '@/data/parsers/yts/models';
|
import { Quality } from '@/data/parsers/yts/models';
|
||||||
import { useM3UUrl } from '@/hooks/useM3UStreamUrl';
|
import { useM3UUrl } from '@/hooks/useM3UStreamUrl';
|
||||||
import { useStreamUrl } from '@/hooks/useStreamUrl';
|
import { useStreamUrl } from '@/hooks/useStreamUrl';
|
||||||
import analytics from '@/lib/analytics';
|
import analytics from '@/lib/analytics';
|
||||||
import { cn, detectSafari, getMagnetHash, isStandaloneApp, seasonFromEpisodes, torrentKey } from '@/lib/utils';
|
import { cn, detectSafari, getMagnetHash, isStandaloneApp, seasonFromEpisodes, torrentKey } from '@/lib/utils';
|
||||||
|
|
||||||
|
import useLaunchedTorrents from '../../../../useLaunchedTorrents';
|
||||||
import usePinnedTorrents from '../../../../usePinnedTorrents';
|
import usePinnedTorrents from '../../../../usePinnedTorrents';
|
||||||
import useUnplayable from '../../../../useUnplayable';
|
import useUnplayable from '../../../../useUnplayable';
|
||||||
|
|
||||||
@@ -47,11 +54,12 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
|
|
||||||
const fetchMagnet = useMagnet(torrent);
|
const fetchMagnet = useMagnet(torrent);
|
||||||
|
|
||||||
const { pin, toggle, isPinned, savedMagnet, rememberMagnet } = usePinnedTorrents();
|
const { savedMagnet, rememberMagnet } = usePinnedTorrents();
|
||||||
|
const { isLaunched, launch } = useLaunchedTorrents();
|
||||||
const { reasonFor } = useUnplayable();
|
const { reasonFor } = useUnplayable();
|
||||||
|
|
||||||
const key = torrentKey(torrent);
|
const key = torrentKey(torrent);
|
||||||
const pinned = isPinned(key);
|
const launched = isLaunched(key);
|
||||||
|
|
||||||
const magnet = fetchMagnet.data || torrent.magnet || savedMagnet(key) || '';
|
const magnet = fetchMagnet.data || torrent.magnet || savedMagnet(key) || '';
|
||||||
|
|
||||||
@@ -60,11 +68,11 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
const unplayable = reasonFor(hash);
|
const unplayable = reasonFor(hash);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pinned && magnet && !torrent.magnet) rememberMagnet(key, magnet);
|
if (magnet && !torrent.magnet) rememberMagnet(key, magnet);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [pinned, magnet, key, torrent.magnet]);
|
}, [magnet, key, torrent.magnet]);
|
||||||
|
|
||||||
const pinPlayed = () => {
|
const trackLaunch = () => {
|
||||||
analytics.torrentSelected({
|
analytics.torrentSelected({
|
||||||
showId: show.id,
|
showId: show.id,
|
||||||
showType: show.type,
|
showType: show.type,
|
||||||
@@ -77,13 +85,18 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
codec: torrent.codec
|
codec: torrent.codec
|
||||||
});
|
});
|
||||||
|
|
||||||
pin(key);
|
launch(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const supportedForCast = prefix && !prefix.includes('{host}');
|
const supportedForCast = prefix && !prefix.includes('{host}');
|
||||||
|
const showCast = Boolean(M3UUrl || supportedForCast);
|
||||||
|
const m3uUrl = `${streamUrl}/stream?m3u&link=${encodeURIComponent(magnet)}`;
|
||||||
|
const vlcUrl = `vlc://${m3uUrl}`;
|
||||||
|
|
||||||
|
const launchedCastClass = 'border-blue-600 bg-blue-600 text-white hover:bg-blue-600 hover:text-white';
|
||||||
|
|
||||||
const handleM3ULink = () => {
|
const handleM3ULink = () => {
|
||||||
pinPlayed();
|
trackLaunch();
|
||||||
setIsStreamPending(true);
|
setIsStreamPending(true);
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
@@ -144,38 +157,22 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
{ invisible: !magnet || fetchMagnet.isPending }
|
{ invisible: !magnet || fetchMagnet.isPending }
|
||||||
)}
|
)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
pinPlayed();
|
trackLaunch();
|
||||||
showPlayerModal({ backdrop: show.backdrop, title, hash, magnet, show, episodes: torrent.episodes });
|
showPlayerModal({ backdrop: show.backdrop, title, hash, magnet, show, episodes: torrent.episodes });
|
||||||
}}
|
}}
|
||||||
title={unplayable ? `Can’t stream in browser: ${unplayable}` : 'Play'}
|
title={unplayable ? `Can’t stream in browser: ${unplayable}` : 'Play'}
|
||||||
>
|
>
|
||||||
<Play size={15} />
|
<Play size={15} fill={launched ? 'currentColor' : 'none'} />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{showCast &&
|
||||||
|
(M3UUrl ? (
|
||||||
<Button
|
<Button
|
||||||
variant='outline'
|
className={cn(
|
||||||
className='grow-0 px-3'
|
'relative h-[32px] w-[45px] grow-0 px-3',
|
||||||
onClick={() => toggle(key)}
|
supportedForStream && '-ml-px',
|
||||||
title={pinned ? 'Unpin' : 'Pin to top'}
|
launched && launchedCastClass
|
||||||
>
|
)}
|
||||||
<Bookmark size={16} className={cn(pinned && 'fill-current')} />
|
|
||||||
</Button>
|
|
||||||
<Button variant='outline' className='relative grow-0 px-3' title='Download m3u playlist'>
|
|
||||||
<a
|
|
||||||
className='absolute left-0 top-0 size-full'
|
|
||||||
target='_blank'
|
|
||||||
rel='noopener noreferrer'
|
|
||||||
href={`${streamUrl}/stream?m3u&link=${encodeURIComponent(magnet)}`}
|
|
||||||
/>
|
|
||||||
<ListVideo size={20} />
|
|
||||||
</Button>
|
|
||||||
<Button className='relative grow-0 px-3' variant='outline' title='Download magnet'>
|
|
||||||
<a className='absolute left-0 top-0 size-full' target='_blank' rel='noopener noreferrer' href={magnet} />
|
|
||||||
<Magnet size={20} />
|
|
||||||
</Button>
|
|
||||||
{M3UUrl ? (
|
|
||||||
<Button
|
|
||||||
className='relative h-[32px] w-[45px] grow-0 px-3'
|
|
||||||
variant='outline'
|
variant='outline'
|
||||||
title='Play m3u playlist'
|
title='Play m3u playlist'
|
||||||
onClick={handleM3ULink}
|
onClick={handleM3ULink}
|
||||||
@@ -190,29 +187,71 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
supportedForCast && (
|
|
||||||
<Button
|
<Button
|
||||||
className='grow-0 px-3'
|
className={cn('grow-0 px-3', supportedForStream && '-ml-px', launched && launchedCastClass)}
|
||||||
variant='outline'
|
variant='outline'
|
||||||
|
title='Cast to TV'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
pinPlayed();
|
trackLaunch();
|
||||||
cast(magnet);
|
cast(magnet);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Cast size={20} />
|
<Cast size={20} />
|
||||||
</Button>
|
</Button>
|
||||||
)
|
))}
|
||||||
|
{!showCast && (
|
||||||
|
<Button variant='outline' className='relative grow-0 px-3' title='Download m3u playlist'>
|
||||||
|
<a className='absolute left-0 top-0 size-full' target='_blank' rel='noopener noreferrer' href={m3uUrl} />
|
||||||
|
<ListVideo size={20} />
|
||||||
|
</Button>
|
||||||
)}
|
)}
|
||||||
{isStandalone && (
|
{!showCast && (
|
||||||
|
<Button className='relative grow-0 px-3' variant='outline' title='Download magnet'>
|
||||||
|
<a className='absolute left-0 top-0 size-full' target='_blank' rel='noopener noreferrer' href={magnet} />
|
||||||
|
<Magnet size={20} />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{!showCast && isStandalone && (
|
||||||
<Button className='relative grow-0 px-3' variant='outline' title='Play in VLC' asChild>
|
<Button className='relative grow-0 px-3' variant='outline' title='Play in VLC' asChild>
|
||||||
<a
|
<a className='absolute left-0 top-0 size-full' rel='noopener noreferrer' href={vlcUrl} />
|
||||||
className='absolute left-0 top-0 size-full'
|
|
||||||
rel='noopener noreferrer'
|
|
||||||
href={`vlc://${streamUrl}/stream?m3u&link=${encodeURIComponent(magnet)}`}
|
|
||||||
/>
|
|
||||||
<TrafficCone size={19} />
|
<TrafficCone size={19} />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{showCast && (
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant='outline'
|
||||||
|
className='h-8 grow-0 rounded-none rounded-r-md border-l-0 px-3 focus-visible:ring-0 data-[state=open]:bg-accent'
|
||||||
|
aria-label='More options'
|
||||||
|
>
|
||||||
|
<MoreHorizontal size={18} />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align='end'>
|
||||||
|
<DropdownMenuItem asChild>
|
||||||
|
<a target='_blank' rel='noopener noreferrer' href={m3uUrl}>
|
||||||
|
<ListVideo />
|
||||||
|
Download m3u playlist
|
||||||
|
</a>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem asChild>
|
||||||
|
<a target='_blank' rel='noopener noreferrer' href={magnet}>
|
||||||
|
<Magnet />
|
||||||
|
Download magnet
|
||||||
|
</a>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{isStandalone && (
|
||||||
|
<DropdownMenuItem asChild>
|
||||||
|
<a rel='noopener noreferrer' href={vlcUrl}>
|
||||||
|
<TrafficCone />
|
||||||
|
Play in VLC
|
||||||
|
</a>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
)}
|
||||||
</ButtonsGroup>
|
</ButtonsGroup>
|
||||||
{!magnet && (
|
{!magnet && (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ import { ArrowDownIcon } from 'lucide-react';
|
|||||||
|
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
||||||
import { Sort } from '@/data/parsers';
|
import { Sort } from '@/data/parsers';
|
||||||
import { cn, torrentKey } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
import usePinnedTorrents from '../../usePinnedTorrents';
|
|
||||||
import showHostManagerModal from '../HostManager';
|
import showHostManagerModal from '../HostManager';
|
||||||
import TableHeadSortable from '../TableHeadSortable';
|
import TableHeadSortable from '../TableHeadSortable';
|
||||||
|
|
||||||
@@ -34,8 +33,6 @@ const TorrentsTable: FC<Props> = ({ title, torrents, show, sort, sortable, provi
|
|||||||
|
|
||||||
const [episodesSort, setEpisodesSort] = useState<EpisodesSort | null>(null);
|
const [episodesSort, setEpisodesSort] = useState<EpisodesSort | null>(null);
|
||||||
|
|
||||||
const { isPinned } = usePinnedTorrents();
|
|
||||||
|
|
||||||
const sorted = episodesSort
|
const sorted = episodesSort
|
||||||
? [...torrents].sort((a, b) => {
|
? [...torrents].sort((a, b) => {
|
||||||
const [seasonA, episodeA] = seasonEpisode(a.episodes);
|
const [seasonA, episodeA] = seasonEpisode(a.episodes);
|
||||||
@@ -46,11 +43,6 @@ const TorrentsTable: FC<Props> = ({ title, torrents, show, sort, sortable, provi
|
|||||||
})
|
})
|
||||||
: torrents;
|
: torrents;
|
||||||
|
|
||||||
const rows = [
|
|
||||||
...sorted.filter((torrent) => isPinned(torrentKey(torrent))),
|
|
||||||
...sorted.filter((torrent) => !isPinned(torrentKey(torrent)))
|
|
||||||
];
|
|
||||||
|
|
||||||
const handleChangeSort = (next: Sort) => {
|
const handleChangeSort = (next: Sort) => {
|
||||||
setEpisodesSort(null);
|
setEpisodesSort(null);
|
||||||
onChangeSort(next);
|
onChangeSort(next);
|
||||||
@@ -59,10 +51,10 @@ const TorrentsTable: FC<Props> = ({ title, torrents, show, sort, sortable, provi
|
|||||||
const toggleEpisodesSort = () => setEpisodesSort((current) => (current === 'asc' ? 'desc' : 'asc'));
|
const toggleEpisodesSort = () => setEpisodesSort((current) => (current === 'asc' ? 'desc' : 'asc'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table className='overflow-hidden rounded-xl'>
|
<Table className='overflow-hidden'>
|
||||||
{Boolean(torrents?.length) && (
|
{Boolean(torrents?.length) && (
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow className='hover:bg-transparent'>
|
<TableRow className='border-border/50 hover:bg-transparent'>
|
||||||
<TableHead className='hidden px-2 md:table-cell'>Title</TableHead>
|
<TableHead className='hidden px-2 md:table-cell'>Title</TableHead>
|
||||||
{isSeries && (
|
{isSeries && (
|
||||||
<TableHead className='hidden cursor-pointer select-none px-2 md:table-cell' onClick={toggleEpisodesSort}>
|
<TableHead className='hidden cursor-pointer select-none px-2 md:table-cell' onClick={toggleEpisodesSort}>
|
||||||
@@ -97,36 +89,36 @@ const TorrentsTable: FC<Props> = ({ title, torrents, show, sort, sortable, provi
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{rows?.map((torrent) => {
|
{sorted.map((torrent) => {
|
||||||
return (
|
return (
|
||||||
<Fragment key={torrent.magnet + torrent.id + torrent.download}>
|
<Fragment key={torrent.magnet + torrent.id + torrent.download}>
|
||||||
<TableRow className='table-row border-b-0 hover:bg-transparent md:hidden'>
|
<TableRow className='table-row border-b-0 md:hidden'>
|
||||||
<TableCell className='break-all p-2' colSpan={colSpan}>
|
<TableCell className='break-all px-2 py-3' colSpan={colSpan}>
|
||||||
<span className='flex w-full flex-wrap items-center gap-3'>
|
<span className='flex w-full flex-wrap items-center gap-3'>
|
||||||
{torrent.title} {isSeries && torrent.episodes && `[${torrent.episodes}]`}{' '}
|
{torrent.title} {isSeries && torrent.episodes && `[${torrent.episodes}]`}{' '}
|
||||||
{torrent.quality && `[${torrent.quality}]`}
|
{torrent.quality && `[${torrent.quality}]`}
|
||||||
</span>
|
</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow className='hover:bg-transparent'>
|
<TableRow className='border-border/50'>
|
||||||
<TableCell className='hidden break-all p-2 md:table-cell' title={torrent.originalTitle}>
|
<TableCell className='hidden break-all px-2 py-3 md:table-cell' title={torrent.originalTitle}>
|
||||||
{torrent.title}
|
{torrent.title}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
{isSeries && (
|
{isSeries && (
|
||||||
<TableCell className='hidden p-2 md:table-cell'>
|
<TableCell className='hidden px-2 py-3 md:table-cell'>
|
||||||
<div className='flex shrink-0 items-center gap-1'>{torrent.episodes}</div>
|
<div className='flex shrink-0 items-center gap-1'>{torrent.episodes}</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
)}
|
)}
|
||||||
<TableCell className='hidden p-2 lg:table-cell'>
|
<TableCell className='hidden px-2 py-3 lg:table-cell'>
|
||||||
<div className='flex shrink-0 items-center gap-1'>{torrent.year}</div>
|
<div className='flex shrink-0 items-center gap-1'>{torrent.year}</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className='hidden p-2 md:table-cell'>
|
<TableCell className='hidden px-2 py-3 md:table-cell'>
|
||||||
<div className='flex shrink-0 items-center gap-1'>{torrent.quality}</div>
|
<div className='flex shrink-0 items-center gap-1'>{torrent.quality}</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className='truncate p-2'>
|
<TableCell className='truncate px-2 py-3'>
|
||||||
<div className='flex shrink-0 items-center gap-1'>{torrent.size}</div>
|
<div className='flex shrink-0 items-center gap-1'>{torrent.size}</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className='truncate p-2'>{torrent.seeders}</TableCell>
|
<TableCell className='truncate px-2 py-3'>{torrent.seeders}</TableCell>
|
||||||
<TableCell className='p-1 pr-2 text-center'>
|
<TableCell className='p-1 pr-2 text-center'>
|
||||||
<Actions show={show} title={title} torrent={torrent} provider={provider} />
|
<Actions show={show} title={title} torrent={torrent} provider={provider} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
|
|||||||
|
|
||||||
const isSeries = show.type === 'tv';
|
const isSeries = show.type === 'tv';
|
||||||
|
|
||||||
|
// Toloka's search is a plain "contains" word-AND match with no IMDB filter, so
|
||||||
|
// scope the query by the show's year to keep, e.g., "Dune" (2021) away from "Dune: Part Two" (2024).
|
||||||
|
const tolokaQuery = query && Number.isFinite(year) ? `${query} ${year}` : query;
|
||||||
|
|
||||||
const tracked = { id: show.id, type: show.type, title: show.title };
|
const tracked = { id: show.id, type: show.type, title: show.title };
|
||||||
|
|
||||||
const yts = useTorrents({
|
const yts = useTorrents({
|
||||||
@@ -71,7 +75,7 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
|
|||||||
show: tracked
|
show: tracked
|
||||||
});
|
});
|
||||||
const tlk = useTorrents({
|
const tlk = useTorrents({
|
||||||
query,
|
query: tolokaQuery,
|
||||||
queryFn: providers.tlk.queryFn,
|
queryFn: providers.tlk.queryFn,
|
||||||
sort,
|
sort,
|
||||||
key: providers.tlk.key,
|
key: providers.tlk.key,
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { useAtom } from 'jotai';
|
||||||
|
import { atomWithStorage } from 'jotai/utils';
|
||||||
|
|
||||||
|
const launchedAtom = atomWithStorage<string[]>('launched-torrents', [], undefined, {
|
||||||
|
unstable_getOnInit: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const useLaunchedTorrents = () => {
|
||||||
|
const [launched, setLaunched] = useAtom(launchedAtom);
|
||||||
|
|
||||||
|
const isLaunched = (key?: string) => Boolean(key) && launched.includes(key!);
|
||||||
|
|
||||||
|
const launch = (key?: string) =>
|
||||||
|
void setLaunched((current) => (!key || current.includes(key) ? current : [...current, key]));
|
||||||
|
|
||||||
|
return { isLaunched, launch };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useLaunchedTorrents;
|
||||||
@@ -1,41 +1,21 @@
|
|||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { atomWithStorage } from 'jotai/utils';
|
import { atomWithStorage } from 'jotai/utils';
|
||||||
|
|
||||||
const pinnedAtom = atomWithStorage<string[]>('pinned-torrents', [], undefined, {
|
|
||||||
unstable_getOnInit: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const magnetsAtom = atomWithStorage<Record<string, string>>('pinned-magnets', {}, undefined, {
|
const magnetsAtom = atomWithStorage<Record<string, string>>('pinned-magnets', {}, undefined, {
|
||||||
unstable_getOnInit: true
|
unstable_getOnInit: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const usePinnedTorrents = () => {
|
const usePinnedTorrents = () => {
|
||||||
const [pinned, setPinned] = useAtom(pinnedAtom);
|
|
||||||
const [magnets, setMagnets] = useAtom(magnetsAtom);
|
const [magnets, setMagnets] = useAtom(magnetsAtom);
|
||||||
|
|
||||||
const isPinned = (key?: string) => Boolean(key) && pinned.includes(key!);
|
|
||||||
|
|
||||||
const savedMagnet = (key?: string) => (key ? magnets[key] : undefined);
|
const savedMagnet = (key?: string) => (key ? magnets[key] : undefined);
|
||||||
|
|
||||||
const forgetMagnet = (key: string) => void setMagnets(({ [key]: _removed, ...rest }) => rest);
|
|
||||||
|
|
||||||
const rememberMagnet = (key?: string, magnet?: string) =>
|
const rememberMagnet = (key?: string, magnet?: string) =>
|
||||||
void setMagnets((current) =>
|
void setMagnets((current) =>
|
||||||
!key || !magnet || current[key] === magnet ? current : { ...current, [key]: magnet }
|
!key || !magnet || current[key] === magnet ? current : { ...current, [key]: magnet }
|
||||||
);
|
);
|
||||||
|
|
||||||
const pin = (key?: string) =>
|
return { savedMagnet, rememberMagnet };
|
||||||
void setPinned((current) => (!key || current.includes(key) ? current : [...current, key]));
|
|
||||||
|
|
||||||
const toggle = (key?: string) => {
|
|
||||||
if (!key) return;
|
|
||||||
|
|
||||||
if (pinned.includes(key)) forgetMagnet(key);
|
|
||||||
|
|
||||||
setPinned((current) => (current.includes(key) ? current.filter((item) => item !== key) : [...current, key]));
|
|
||||||
};
|
|
||||||
|
|
||||||
return { pinned, isPinned, pin, toggle, savedMagnet, rememberMagnet };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default usePinnedTorrents;
|
export default usePinnedTorrents;
|
||||||
+3
-1
@@ -49,7 +49,9 @@ export const getMagnetHash = (link: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const torrentKey = (torrent: Torrent) =>
|
export const torrentKey = (torrent: Torrent) =>
|
||||||
torrent.download || getMagnetHash(torrent.magnet) || torrent.hash || torrent.id;
|
torrent.download
|
||||||
|
? torrent.download.replace(/[?&]sid=[^&]*/, '')
|
||||||
|
: getMagnetHash(torrent.magnet) || torrent.hash || torrent.id;
|
||||||
|
|
||||||
export const parseSeasonEpisode = (value?: string): { season?: number; episode?: number } => {
|
export const parseSeasonEpisode = (value?: string): { season?: number; episode?: number } => {
|
||||||
const [, season, episode] =
|
const [, season, episode] =
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
"mcp": {
|
||||||
|
"shadcn": {
|
||||||
|
"type": "local",
|
||||||
|
"command": ["npx", "-y", "shadcn@latest", "mcp"],
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -107,7 +107,7 @@
|
|||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
|
|
||||||
body [data-overlay]:not(:last-of-type) {
|
body [data-overlay]:has(~ [data-overlay]) {
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user