From c52d79822100c35f2ec8ad4f43de88086150dc43 Mon Sep 17 00:00:00 2001 From: ner Date: Sun, 13 Sep 2026 14:06:27 +0300 Subject: [PATCH] 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) --- .dockerignore | 8 + Dockerfile | 31 ++++ components/Header/components/Search/index.tsx | 6 +- .../Header/components/Search/useSearch.ts | 4 +- .../components/Actions/index.tsx | 155 +++++++++++------- .../components/TorrentsTable/index.tsx | 34 ++-- .../Preview/components/Torrents/index.tsx | 6 +- .../Torrents/useLaunchedTorrents.ts | 19 +++ .../components/Torrents/usePinnedTorrents.ts | 22 +-- lib/utils.ts | 4 +- opencode.json | 10 ++ styles/index.css | 2 +- 12 files changed, 194 insertions(+), 107 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 components/Preview/components/Torrents/useLaunchedTorrents.ts create mode 100644 opencode.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7bf443d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +.next +.git +.env +.env.local +Dockerfile +.dockerignore +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..efe25c9 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/components/Header/components/Search/index.tsx b/components/Header/components/Search/index.tsx index b12a9b3..29b8f50 100644 --- a/components/Header/components/Search/index.tsx +++ b/components/Header/components/Search/index.tsx @@ -21,9 +21,11 @@ export const showSearchModal = create(({ onResolve }) => { const isFetchedRef = useRef(false); const query = useDistinctUntilChanged(title); + const settledTitle = useDistinctUntilChanged(title, 1000); + const settled = title === settledTitle; - const movies = useSearch({ query, type: 'movie' }); - const series = useSearch({ query, type: 'tv' }); + const movies = useSearch({ query, type: 'movie', settled }); + const series = useSearch({ query, type: 'tv', settled }); const handleChangeTitle = ({ target: { value } }: ChangeEvent) => setTitle(value); diff --git a/components/Header/components/Search/useSearch.ts b/components/Header/components/Search/useSearch.ts index 2df77bc..725ee80 100644 --- a/components/Header/components/Search/useSearch.ts +++ b/components/Header/components/Search/useSearch.ts @@ -5,14 +5,14 @@ import useInfiniteList from '@/hooks/useInfiniteList'; import analytics from '@/lib/analytics'; import useTrackOnce from '@/lib/analytics/useTrackOnce'; -const useSearch = (props: SearchQueryProps) => { +const useSearch = (props: SearchQueryProps & { settled: boolean }) => { const previousRef = useRef([]); const infiniteQuery = useInfiniteList({ ...searchQuery(props), mode: 'default', list: 'search' }); useTrackOnce( 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 }) ); diff --git a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx index b2d1eac..8ea4f0a 100644 --- a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx +++ b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx @@ -1,16 +1,23 @@ 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 { useCastMagnet, usePrefix } from '@/components/Preview/components/Torrents/hooks/useMagnetHosts'; import { Button } from '@/components/ui/button'; 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 { useM3UUrl } from '@/hooks/useM3UStreamUrl'; import { useStreamUrl } from '@/hooks/useStreamUrl'; import analytics from '@/lib/analytics'; import { cn, detectSafari, getMagnetHash, isStandaloneApp, seasonFromEpisodes, torrentKey } from '@/lib/utils'; +import useLaunchedTorrents from '../../../../useLaunchedTorrents'; import usePinnedTorrents from '../../../../usePinnedTorrents'; import useUnplayable from '../../../../useUnplayable'; @@ -47,11 +54,12 @@ const Actions: FC = ({ torrent, title, provider, show }) => { const fetchMagnet = useMagnet(torrent); - const { pin, toggle, isPinned, savedMagnet, rememberMagnet } = usePinnedTorrents(); + const { savedMagnet, rememberMagnet } = usePinnedTorrents(); + const { isLaunched, launch } = useLaunchedTorrents(); const { reasonFor } = useUnplayable(); const key = torrentKey(torrent); - const pinned = isPinned(key); + const launched = isLaunched(key); const magnet = fetchMagnet.data || torrent.magnet || savedMagnet(key) || ''; @@ -60,11 +68,11 @@ const Actions: FC = ({ torrent, title, provider, show }) => { const unplayable = reasonFor(hash); useEffect(() => { - if (pinned && magnet && !torrent.magnet) rememberMagnet(key, magnet); + if (magnet && !torrent.magnet) rememberMagnet(key, magnet); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [pinned, magnet, key, torrent.magnet]); + }, [magnet, key, torrent.magnet]); - const pinPlayed = () => { + const trackLaunch = () => { analytics.torrentSelected({ showId: show.id, showType: show.type, @@ -77,13 +85,18 @@ const Actions: FC = ({ torrent, title, provider, show }) => { codec: torrent.codec }); - pin(key); + launch(key); }; 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 = () => { - pinPlayed(); + trackLaunch(); setIsStreamPending(true); const params = new URLSearchParams({ @@ -144,75 +157,101 @@ const Actions: FC = ({ torrent, title, provider, show }) => { { invisible: !magnet || fetchMagnet.isPending } )} onClick={() => { - pinPlayed(); + trackLaunch(); showPlayerModal({ backdrop: show.backdrop, title, hash, magnet, show, episodes: torrent.episodes }); }} title={unplayable ? `Can’t stream in browser: ${unplayable}` : 'Play'} > - + )} - - - - {M3UUrl ? ( - - ) : ( - supportedForCast && ( + {showCast && + (M3UUrl ? ( + ) : ( + - ) + ))} + {!showCast && ( + )} - {isStandalone && ( + {!showCast && ( + + )} + {!showCast && isStandalone && ( )} + {showCast && ( + + + + + + + + + Download m3u playlist + + + + + + Download magnet + + + {isStandalone && ( + + + + Play in VLC + + + )} + + + )} {!magnet && (