# Watch Next (movie-advisor) **Self-hosted movie & TV discovery and watch app.** Find what to watch, then actually watch it — one click from a torrent release to a streaming player, without leaving the site. Live instance: **https://watchnext.online** · built with [Next.js](https://nextjs.org) (App Router), [TMDB](https://developer.themoviedb.org/docs) as the metadata backbone. ## Screens | Discovery — random pick hero, rails by mood | Unified search (movies + series) | |---|---| | ![home](docs/screenshots/01-home.jpg) | ![search](docs/screenshots/02-search.jpg) | | Title page — cast, similar, recommendations | Watch modal — releases from 4 providers | |---|---| | ![movie](docs/screenshots/03-movie.jpg) | ![watch](docs/screenshots/04-watch-modal.jpg) | Provider tabs are sortable by seeders/resolution/size; each release has three actions: **stream in-app**, **export to player** (M3U, works with Kodi/mpv/VLC), or **grab the magnet**. ## Features - **Discovery** — Random pick, Popular, Top rated, Streaming / Trending / In theaters rails, movie⇄TV switcher, Similar & Recommendations. - **Search** — unified movies + series search, ranked by votes-weighted rating; results with no title-token overlap are dropped (TMDB loose-match noise). - **Personal** — favorites, watchlist, share links; dark/light theme; PWA installable. - **Multi-provider torrents** — YTS, The Pirate Bay, TorrentGalaxy, Toloka in the UI; 0day.community available API-only. IMDb-first matching with inline magnets (Galaxy). - **Instant streaming** — server-side stream endpoint converts a magnet into an on-the-fly m3u/HTTP stream; in-app [Vidstack](https://vidstack.app) player; external subtitles via OpenSubtitles. - **SEO & analytics** — SSR/ISR pages, sitemap, dynamic OG images, JSON-LD; OpenPanel with client-side bot filtering and TMDB-username profileIds. ## Architecture notes - **API routes**: `/api/tmdb`, `/api/torrents`, `/api/magnet`, `/api/refresh` (re-pull a provider thread), `/api/subtitles`. - **Bounded ISR cache** ([`cache-handler.js`](cache-handler.js)): Next.js page/fetch cache lives in one SQLite file with LRU eviction (`NEXT_CACHE_MAX_MB`), so crawler traffic can't grow the cache without limit. - **Toloka sessions persist in Redis** (Upstash) across cold starts; sortable, deduplicated release lists are rendered with `react-virtuoso`. - **Deploy**: Next standalone output → ~289 MB Docker image; runs behind Traefik (Let's Encrypt) via Coolify; `stream.` serves the m3u endpoint (also used by the companion Kodi add-on). ## Stack Next.js 14 · React 18 · TypeScript · Tailwind + shadcn/ui (Radix) · TanStack Query · Jotai · Vidstack · cheerio (provider scraping) · Upstash Redis · OpenPanel ## Getting started ```bash cp env.example .env # required: MOVIE_DB_TOKEN (TMDB API key) # per-provider hosts; TOLOKA_* / ODC_* credentials for the tracker-backed sources # optional: OPENSUBTITLES_* (subtitles), NEXT_PUBLIC_OPENPANEL_CLIENT_ID (analytics), # NEXT_PUBLIC_TORRENT_PROXY (magnet→http proxy for in-app streaming) npm install npm run dev # http://localhost:3000 ``` Production: ```bash npm run build && npm run start # or docker build -t watchnext . ``` --- *Personal project — self-host and fork freely; the public instance runs on a small VPS.*