diff --git a/api/index.ts b/api/index.ts index 5bded55..96bf482 100644 --- a/api/index.ts +++ b/api/index.ts @@ -40,7 +40,7 @@ export const details = async ({ }): Promise => { return http .get<(Movie | Series) & Details>(`/${showType}/${showId}`) - .then((response) => ({ ...mapMovieSeriesToShow(response, showType), ...response })); + .then((response) => ({ ...response, ...mapMovieSeriesToShow(response, showType) })); }; export const randomMovies = async (): Promise> => { @@ -82,7 +82,7 @@ export const popularMovies = async ({ page }: { page?: string } = {}): Promise

mapMoviesSeriesResponseToShows(response, showType)); }; -export const externalIDs = async ({ - showId, - showType = 'movie' -}: { - showType: Show['type']; - showId: Show['id']; -}): Promise => { - return http.get(`/${showType}/${showId}/external_ids`).then(({ imdb_id }) => imdb_id); -}; - export const credits = async ({ showId, showType = 'movie' @@ -164,13 +154,17 @@ export const credits = async ({ `/${showType}/${showId}/${showType === 'tv' ? 'aggregate_credits' : 'credits'}` ) .then(({ cast }) => { - return cast.map((actor) => { - if ('character' in actor) return actor; + return cast + .filter((person) => person.profile_path) + .map((actor) => { + const photoUrl = `https://image.tmdb.org/t/p/w500/${actor.profile_path}`; - const [{ character }] = actor.roles || [{}]; + if ('character' in actor) return { ...actor, photoUrl }; - return { ...actor, character }; - }); + const [{ character }] = actor.roles || [{}]; + + return { ...actor, character, photoUrl }; + }); }); }; @@ -190,15 +184,7 @@ export const trailers = async ({ .then((data) => data.results); }; -export const YTSTorrents = async ({ - query, - sort, - imdbID -}: { - imdbID: string; - query: string; - sort: Sort; -}) => { +export const YTSTorrents = async ({ query, sort, imdbID }: { imdbID: string; query: string; sort: Sort }) => { try { return yts.search({ imdbID, @@ -210,19 +196,12 @@ export const YTSTorrents = async ({ } }; -export const TPBTorrents = async ({ - query, - sort -}: { - imdbID: string; - query: string; - sort: Sort; -}) => { +export const TPBTorrents = async ({ query, sort }: { imdbID: string; query: string; sort: Sort }) => { try { return pirateBay.search({ query, sort - }) + }); } catch (error) { return []; } diff --git a/api/parsers/pirate-bay.ts b/api/parsers/pirate-bay.ts index 03d34a8..d80a511 100644 --- a/api/parsers/pirate-bay.ts +++ b/api/parsers/pirate-bay.ts @@ -1,5 +1,6 @@ import axios, { AxiosInstance } from 'axios'; import { parse } from 'node-html-parser'; +import torrentTitle from 'parse-torrent-title'; import { Sort } from './index'; @@ -47,12 +48,22 @@ export class PirateBay { const magnets = table?.querySelectorAll('a[href^="magnet:"]').map((link) => link.getAttribute('href')); - return titles.map((title, index) => { + return titles.map((originalTitle, index) => { + const { title, resolution, source, codec, container, season, episode, year } = torrentTitle.parse( + originalTitle || '' + ); + return { - title, + year, + source, + codec, + container, + originalTitle, + title: `${title} ${season && episode ? `[S${season}:E${episode}]` : ''}`, id: title, size: sizes[index], seeders: parseInt(seeders[index]!), + quality: resolution, magnet: magnets[index]! }; }) as Torrent[]; diff --git a/api/parsers/yts/index.ts b/api/parsers/yts/index.ts index eb06ce0..1b7c1ac 100644 --- a/api/parsers/yts/index.ts +++ b/api/parsers/yts/index.ts @@ -50,10 +50,12 @@ export class YTS { return { id: movie.id?.toString(), - title: `${movie.title_english} ${torrent.quality ? `[${torrent.quality}]` : ''}`, + title: movie.title_english, seeders: torrent.seeds, size: torrent.size, - type: torrent.type, + quality: torrent.quality, + source: torrent.type, + year: movie.year?.toString(), magnet: `magnet:?xt=urn:btih:${torrent.hash}&dn=${encodeURIComponent(query)}&tr=${trackers.join('&tr=')}` }; }) || [] diff --git a/app/(site)/popular/container.tsx b/app/(site)/popular/container.tsx index f885947..82cc863 100644 --- a/app/(site)/popular/container.tsx +++ b/app/(site)/popular/container.tsx @@ -2,6 +2,7 @@ import List from '@/components/List'; import NoResults from '@/components/NoResults'; +import { Player } from '@/components/Show/components/Torrents/components/Player'; import usePopular from './usePopular'; @@ -10,7 +11,15 @@ const Container = () => { if (isFetched && !shows.length) return ; - return ; + return ( + <> + + + + ); }; export default Container; diff --git a/app/layout.tsx b/app/layout.tsx index 99d236b..8154331 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -29,7 +29,7 @@ const RootLayout = ({ children }: { children: ReactNode }) => { const theme = cookies().get('theme')?.value as Theme; return ( - + diff --git a/components/Header/components/ThemeToggle/index.tsx b/components/Header/components/ThemeToggle/index.tsx index 533df5e..541599d 100644 --- a/components/Header/components/ThemeToggle/index.tsx +++ b/components/Header/components/ThemeToggle/index.tsx @@ -9,7 +9,12 @@ const ThemeToggle = () => { const [theme, setTheme] = useTheme(); return ( - ); diff --git a/components/Preview/index.tsx b/components/Preview/index.tsx index 0163a05..dc0262f 100644 --- a/components/Preview/index.tsx +++ b/components/Preview/index.tsx @@ -25,7 +25,7 @@ const Preview: FC = ({ show: baseShow, className, onClose, children, card if (!baseShow) return null; - const show: Show & Partial

| undefined = detailedShow || baseShow; + const show: (Show & Partial
) | undefined = detailedShow || baseShow; return (
diff --git a/components/Show/components/Credits/index.tsx b/components/Show/components/Credits/index.tsx index cd53fdb..764814c 100644 --- a/components/Show/components/Credits/index.tsx +++ b/components/Show/components/Credits/index.tsx @@ -38,13 +38,7 @@ const Credits: FC = ({ showId, showType = 'movie', onPersonClick }) => { >
{actor.profile_path ? ( - {actor.name} + {actor.name} ) : (
diff --git a/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx b/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx new file mode 100644 index 0000000..12cd995 --- /dev/null +++ b/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx @@ -0,0 +1,38 @@ +import { FC, ReactNode } from 'react'; +import { Menu } from '@vidstack/react'; +import { CheckIcon } from '@vidstack/react/icons'; + +import { cn } from '@/lib/utils'; + +type Option = { onClick: () => void; label: string }; + +interface Props { + children: ReactNode; + options: Option[]; + isChecked: (option: Option) => boolean; +} + +const PlayerMenu: FC = ({ children, options, isChecked }) => ( + + + {children} + + + + {options.map((option) => ( + + + {option.label} + + ))} + + + +); + +export default PlayerMenu; diff --git a/components/Show/components/Torrents/components/Player/index.tsx b/components/Show/components/Torrents/components/Player/index.tsx index 3b0705c..d6765a5 100644 --- a/components/Show/components/Torrents/components/Player/index.tsx +++ b/components/Show/components/Torrents/components/Player/index.tsx @@ -1,74 +1,119 @@ 'use client'; -import { useEffect, useState } from 'react'; +import { FC, useRef } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; -import { Loader } from 'lucide-react'; -import { BigPlayButton, ClosedCaptionButton, ControlBar, Player, PlayerReference } from 'video-react'; +import { + MediaPlayer, + MediaPlayerInstance, + MediaProvider, + Poster, + Track, + useActiveTextTrack, + useCaptionOptions, + useMediaPlayer, + useMediaStore, + VideoSrc +} from '@vidstack/react'; +import { ClosedCaptionsIcon, ClosedCaptionsOnIcon, PlaylistIcon } from '@vidstack/react/icons'; +import { defaultLayoutIcons, DefaultVideoLayout } from '@vidstack/react/player/layouts/default'; import { Modal } from '@/components/ui/dialog'; import { useToast } from '@/hooks/useToast'; +import { cn } from '@/lib/utils'; -import useSubtitles from './useSubtitles'; +import PlayerMenu from './components/PlayerMenu'; +import useFiles from './useFiles'; -interface Props extends InstanceProps { +import '@vidstack/react/player/styles/default/theme.css'; +import '@vidstack/react/player/styles/default/layouts/video.css'; + +interface Props { magnet: string; backdrop: string; + className?: string; } -type PlayerRef = PlayerReference & { video: { video: HTMLVideoElement } }; - -const showPlayer = create(({ onResolve, magnet, backdrop }: Props) => { - const [player, setPlayer] = useState(null); - const [isLoading, setIsLoading] = useState(true); - const { toast } = useToast(); - const { data: subtitles } = useSubtitles({ magnet }); - - useEffect(() => { - if (!player) return; - - const { video } = player.video; - - const handleCanPlay = () => setIsLoading(false); - - video.addEventListener('canplay', handleCanPlay); - - return () => video.removeEventListener('canplay', handleCanPlay); - }, [player]); +const CaptionsMenu = () => { + const track = useActiveTextTrack(['subtitles']); + const tracks = useCaptionOptions(); + return ( + ({ label: track.label, onClick: () => track.select() }))} + isChecked={({ label }) => (label === 'Off' ? !track : label === track?.label)} + > + {track ? : } + + ); +}; + +const VideosMenu = () => { + const player = useMediaPlayer(); + const { sources, source } = useMediaStore(); + + player?.remoteControl.console.log(sources, source); + + return null; + + return ( + ({ label: track.label, onClick: () => track.select() }))} + isChecked={({ label }) => (label === 'Off' ? !track : label === track?.label)} + > + {track ? : } + + ); +}; + +export const Player: FC = ({ magnet, backdrop, className }) => { + const { toast } = useToast(); + const player = useRef(null); + + const { + data: { subtitles, videos } + } = useFiles(magnet); + + return ( + + + + {subtitles.map((track) => ( + + ))} + + , + afterSettingsMenu: Boolean(subtitles.length) && + }} + /> + + ); +}; + +const showPlayer = create(({ onResolve, magnet, backdrop, className }: Props & InstanceProps) => { return ( - setPlayer(player as PlayerRef)}> - {subtitles?.map(({ name, content }) => ( - - ))} - { - toast({ title: 'This torrent doesn\'t contain any compatible video files' }); - setIsLoading(false); - }} - /> - {Boolean(subtitles?.length) && } - - - {isLoading && ( - <> -
-
- -
-
- - )} +
); }); diff --git a/components/Show/components/Torrents/components/Player/useFiles.ts b/components/Show/components/Torrents/components/Player/useFiles.ts new file mode 100644 index 0000000..1e30462 --- /dev/null +++ b/components/Show/components/Torrents/components/Player/useFiles.ts @@ -0,0 +1,33 @@ +import { useQuery } from '@tanstack/react-query'; + +export type Source = { name: string; src: string; type: string }; +type Sources = { subtitles: Source[]; videos: Source[] }; + +const useFiles = (magnet: string) => { + const STREAM_URL = `${process.env.NEXT_PUBLIC_TORRENT_PROXY}/stream?link=${encodeURIComponent(magnet)}`; + + const query = useQuery({ + queryKey: ['files', magnet], + queryFn: () => fetch(`${STREAM_URL}&stat`).then((response) => response.json()) + }); + + return { + ...query, + data: (query.data?.file_stats || []).reduce( + (sources, file) => { + if (file.path.endsWith('.mp4')) { + sources.videos.push({ src: `${STREAM_URL}&index=${file.id}&play`, name: file.path, type: 'video/mp4' }); + } + + if (file.path.endsWith('.srt')) { + sources.subtitles.push({ src: `${STREAM_URL}&index=${file.id}&play`, name: file.path, type: 'srt' }); + } + + return sources; + }, + { subtitles: [], videos: [] } + ) + }; +}; + +export default useFiles; diff --git a/components/Show/components/Torrents/components/Player/useSubtitles.ts b/components/Show/components/Torrents/components/Player/useSubtitles.ts deleted file mode 100644 index faba530..0000000 --- a/components/Show/components/Torrents/components/Player/useSubtitles.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; - -interface Props { - magnet: string; -} - -const useSubtitles = ({ magnet }: Props) => - useQuery({ - queryKey: [magnet], - queryFn: () => - fetch(`${process.env.NEXT_PUBLIC_TRACKER_PROXY_BASE}/subtitles?magnet=${encodeURIComponent(magnet)}`).then( - (response) => response.json() - ) - }); - -export default useSubtitles; diff --git a/components/Show/components/Torrents/index.tsx b/components/Show/components/Torrents/index.tsx index abb4ba6..833c063 100644 --- a/components/Show/components/Torrents/index.tsx +++ b/components/Show/components/Torrents/index.tsx @@ -1,8 +1,9 @@ import React, { Fragment, useState } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; -import { Cast, Copy, Loader, Magnet, Play } from 'lucide-react'; +import { Cast, Copy, ListVideo, Loader, Magnet, Play } from 'lucide-react'; import { Sort } from '@/api/parsers'; +import { Quality } from '@/api/parsers/yts/models'; import { Button } from '@/components/ui/button'; import { Modal } from '@/components/ui/dialog'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; @@ -23,7 +24,6 @@ interface Props extends InstanceProps { } const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: Props) => { - const isMobile = matchMedia('(max-width: 600px)').matches; const prefix = usePrefix(); const [sort, setSort] = useState(Sort.seeds); const [withYear, setWithYear] = useState(true); @@ -34,6 +34,7 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: const { data: torrents, isLoading, + isFetching, isFetched } = useTorrents({ query, @@ -45,12 +46,14 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: const cast = useCastMagnet(); + const colSpan = 5; + return ( - + - +
{title}
- {!isMobile && Title} + Title + Resolution showHostManagerModal()} /> + {torrents?.map((torrent) => { const supportedForStream = Boolean( - key === providers.yts.key && + (key === providers.yts.key && torrent.seeders && - ['720p', '1080p'].some((resolution) => torrent.title.includes(resolution)) + [Quality.The1080P, Quality.The720P].includes(torrent.quality as Quality)) || + torrent.container?.includes('mp4') ); + const supportedForCast = prefix && !prefix.includes('{host}'); + return ( - {isMobile && ( - - - {torrent.title} - - - )} + + + + {torrent.title} {torrent.year && `[${torrent.year}]`} {torrent.quality && `[${torrent.quality}]`} + + + - {!isMobile && ( - - {torrent.title} {torrent.type && `[${torrent.type?.toUpperCase()}]`} - - )} + + {torrent.title} {torrent.year && `[${torrent.year}]`}{' '} + {torrent.source && `[${torrent.source}]`} + + +
{torrent.quality}
+
{torrent.size}
@@ -116,20 +126,35 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }:
showPlayer({ magnet: torrent.magnet, backdrop })} + title='Play show' >
)} - + + + +
navigator.clipboard.writeText(torrent.magnet)} + title='Copy magnet into clipboard' >
- {prefix && !prefix.includes('{host}') && ( + {supportedForCast && (
cast(torrent.magnet!)} className='flex size-8 cursor-pointer items-center justify-center rounded-lg border' @@ -143,18 +168,20 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: ); })} - {isLoading && ( + + {(isLoading || isFetching) && ( - +
)} - {!isLoading && isFetched && !torrents?.length && ( + + {!(isLoading || isFetching) && isFetched && !torrents?.length && ( - +
Nothing was found
diff --git a/components/Show/components/Torrents/useTorrents.ts b/components/Show/components/Torrents/useTorrents.ts index efe8162..1f7370a 100644 --- a/components/Show/components/Torrents/useTorrents.ts +++ b/components/Show/components/Torrents/useTorrents.ts @@ -13,7 +13,7 @@ const useTorrents = ({ query: string; sort: Sort; imdbID: string; - queryFn: (params: { query: string; sort: Sort; imdbID: string; }) => Promise; + queryFn: (params: { query: string; sort: Sort; imdbID: string }) => Promise; }) => { return useQuery({ enabled: Boolean(query), diff --git a/components/Trending/index.tsx b/components/Trending/index.tsx index fbe93c4..d6247a8 100644 --- a/components/Trending/index.tsx +++ b/components/Trending/index.tsx @@ -10,17 +10,16 @@ import useTrending from './useTrending'; const Trending: FC = () => { const [active, setActive] = useState(tabs[0]); - const isMobile = typeof window === 'undefined' ? true : matchMedia('(max-width: 600px)').matches; - const { data: trending, isFetched } = useTrending({ type: 'trending', enabled: !isMobile }); - const { data: streaming } = useTrending({ type: 'streaming', enabled: !isMobile }); - const { data: theater } = useTrending({ type: 'theater', enabled: !isMobile }); + const { data: trending, isFetched } = useTrending({ type: 'trending' }); + const { data: streaming } = useTrending({ type: 'streaming' }); + const { data: theater } = useTrending({ type: 'theater' }); const shows = { trending, streaming, theater }[active.type] || []; return ( isFetched && ( -
+
diff --git a/env.example b/env.example index c0d8373..db08ac6 100644 --- a/env.example +++ b/env.example @@ -1,4 +1,4 @@ MOVIE_DB_TOKEN=YOUR_TOKEN -NEXT_PUBLIC_TRACKER_PROXY_BASE=HOST_URL_OF_YOUR_INSTANCE #https://github.com/noisy5ilence/tracker-proxy PIRATE_BAY_HOST=https://thepiratebay10.org YTS_HOST=https://yts.mx/api/v2/list_movies.json +NEXT_PUBLIC_TORRENT_PROXY=http://localhost:8090 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 032181c..74a4026 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@radix-ui/react-toast": "^1.2.2", "@radix-ui/react-toggle": "^1.0.3", "@tanstack/react-query": "^5.17.3", + "@vidstack/react": "^1.12.11", "axios": "^1.4.0", "class-variance-authority": "^0.7.0", "classnames": "^2.3.2", @@ -27,8 +28,10 @@ "jotai": "^2.2.2", "js-cookie": "^3.0.5", "lucide-react": "^0.263.0", + "media-icons": "^1.1.5", "next": "^14.2.7", "node-html-parser": "^6.1.5", + "parse-torrent-title": "^1.4.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-modal-promise": "^1.0.2", @@ -137,16 +140,20 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.3.1.tgz", - "integrity": "sha512-Bu+AMaXNjrpjh41znzHqaz3r2Nr8hHuHZT6V2LBKMhyMl0FgKA62PNYbqnfgmzOhoWZj70Zecisbo4H1rotP5g==" + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.8.tgz", + "integrity": "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==", + "dependencies": { + "@floating-ui/utils": "^0.2.8" + } }, "node_modules/@floating-ui/dom": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.4.5.tgz", - "integrity": "sha512-96KnRWkRnuBSSFbj0sFGwwOUd8EkiecINVl0O9wiZlZ64EkpyAOG3Xc2vKKNJmru0Z7RqWNymA+6b8OZqjgyyw==", + "version": "1.6.11", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.11.tgz", + "integrity": "sha512-qkMCxSR24v2vGkhYDo/UzxfJN3D4syqSjyuTFz6C7XcpU1pASPRieNI0Kj5VP3/503mOfYiGY891ugBX1GlABQ==", "dependencies": { - "@floating-ui/core": "^1.3.1" + "@floating-ui/core": "^1.6.0", + "@floating-ui/utils": "^0.2.8" } }, "node_modules/@floating-ui/react-dom": { @@ -161,6 +168,11 @@ "react-dom": ">=16.8.0" } }, + "node_modules/@floating-ui/utils": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz", + "integrity": "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==" + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", @@ -2083,14 +2095,12 @@ "node_modules/@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", - "devOptional": true + "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" }, "node_modules/@types/react": { "version": "18.2.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.15.tgz", "integrity": "sha512-oEjE7TQt1fFTFSbf8kkNuc798ahTUzn3Le67/PWjE8MAfYAD/qB7O8hSTcromLFqHCt9bcdOg5GXMokzTjJ5SA==", - "devOptional": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -2109,8 +2119,7 @@ "node_modules/@types/scheduler": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==", - "devOptional": true + "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" }, "node_modules/@types/video-react": { "version": "0.15.8", @@ -2217,6 +2226,22 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@vidstack/react": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@vidstack/react/-/react-1.12.11.tgz", + "integrity": "sha512-rtSRjjob1k/mkzImN0wWPKYFi/Y7bsuSkDl/RfTxTKlDs4QzFtVwkUfgN1h8y+EUKJvMe9ozVHKdBtGYKDr6FQ==", + "dependencies": { + "@floating-ui/dom": "^1.6.10", + "media-captions": "^1.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/react": "^18.0.0", + "react": "^18.0.0" + } + }, "node_modules/acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", @@ -3108,8 +3133,7 @@ "node_modules/csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "devOptional": true + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/damerau-levenshtein": { "version": "1.0.8", @@ -5115,6 +5139,22 @@ "react": "^16.5.1 || ^17.0.0 || ^18.0.0" } }, + "node_modules/media-captions": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/media-captions/-/media-captions-1.0.4.tgz", + "integrity": "sha512-cyDNmuZvvO4H27rcBq2Eudxo9IZRDCOX/I7VEyqbxsEiD2Ei7UYUhG/Sc5fvMZjmathgz3fEK7iAKqvpY+Ux1w==", + "engines": { + "node": ">=16" + } + }, + "node_modules/media-icons": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/media-icons/-/media-icons-1.1.5.tgz", + "integrity": "sha512-zu3CjKRs63ybLLWPomRRgTDyYiSrk2bRRgw97ZmN3FGXuo9qUUhBSfYwnjmvSdLG2JOJfAwzDz99bPATSY81DQ==", + "engines": { + "node": ">=16" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -5563,6 +5603,14 @@ "node": ">=6" } }, + "node_modules/parse-torrent-title": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/parse-torrent-title/-/parse-torrent-title-1.4.0.tgz", + "integrity": "sha512-/G0rQNeAUmNwB3QtyBJtNDAr1Q95Gg3wgwQ3dbYEkX8tOdkw5XmUS03O3+QqAV5hDNRVMatBG2fIoz+H/UMseQ==", + "engines": { + "node": ">=8" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7235,16 +7283,20 @@ "integrity": "sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==" }, "@floating-ui/core": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.3.1.tgz", - "integrity": "sha512-Bu+AMaXNjrpjh41znzHqaz3r2Nr8hHuHZT6V2LBKMhyMl0FgKA62PNYbqnfgmzOhoWZj70Zecisbo4H1rotP5g==" + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.8.tgz", + "integrity": "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==", + "requires": { + "@floating-ui/utils": "^0.2.8" + } }, "@floating-ui/dom": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.4.5.tgz", - "integrity": "sha512-96KnRWkRnuBSSFbj0sFGwwOUd8EkiecINVl0O9wiZlZ64EkpyAOG3Xc2vKKNJmru0Z7RqWNymA+6b8OZqjgyyw==", + "version": "1.6.11", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.11.tgz", + "integrity": "sha512-qkMCxSR24v2vGkhYDo/UzxfJN3D4syqSjyuTFz6C7XcpU1pASPRieNI0Kj5VP3/503mOfYiGY891ugBX1GlABQ==", "requires": { - "@floating-ui/core": "^1.3.1" + "@floating-ui/core": "^1.6.0", + "@floating-ui/utils": "^0.2.8" } }, "@floating-ui/react-dom": { @@ -7255,6 +7307,11 @@ "@floating-ui/dom": "^1.3.0" } }, + "@floating-ui/utils": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz", + "integrity": "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==" + }, "@humanwhocodes/config-array": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", @@ -8247,14 +8304,12 @@ "@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", - "devOptional": true + "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" }, "@types/react": { "version": "18.2.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.15.tgz", "integrity": "sha512-oEjE7TQt1fFTFSbf8kkNuc798ahTUzn3Le67/PWjE8MAfYAD/qB7O8hSTcromLFqHCt9bcdOg5GXMokzTjJ5SA==", - "devOptional": true, "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -8273,8 +8328,7 @@ "@types/scheduler": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==", - "devOptional": true + "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" }, "@types/video-react": { "version": "0.15.8", @@ -8333,6 +8387,15 @@ "eslint-visitor-keys": "^3.3.0" } }, + "@vidstack/react": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@vidstack/react/-/react-1.12.11.tgz", + "integrity": "sha512-rtSRjjob1k/mkzImN0wWPKYFi/Y7bsuSkDl/RfTxTKlDs4QzFtVwkUfgN1h8y+EUKJvMe9ozVHKdBtGYKDr6FQ==", + "requires": { + "@floating-ui/dom": "^1.6.10", + "media-captions": "^1.0.4" + } + }, "acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", @@ -8953,8 +9016,7 @@ "csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "devOptional": true + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "damerau-levenshtein": { "version": "1.0.8", @@ -10353,6 +10415,16 @@ "integrity": "sha512-F+rHswbbI1xuDZ/OzofiJZJVlBPOIYVVST705cPdRLImJ5aOJNXYaFBPNo3qdUV0iEG/4nZeiUtLSHO2qU2ISw==", "requires": {} }, + "media-captions": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/media-captions/-/media-captions-1.0.4.tgz", + "integrity": "sha512-cyDNmuZvvO4H27rcBq2Eudxo9IZRDCOX/I7VEyqbxsEiD2Ei7UYUhG/Sc5fvMZjmathgz3fEK7iAKqvpY+Ux1w==" + }, + "media-icons": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/media-icons/-/media-icons-1.1.5.tgz", + "integrity": "sha512-zu3CjKRs63ybLLWPomRRgTDyYiSrk2bRRgw97ZmN3FGXuo9qUUhBSfYwnjmvSdLG2JOJfAwzDz99bPATSY81DQ==" + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -10650,6 +10722,11 @@ "callsites": "^3.0.0" } }, + "parse-torrent-title": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/parse-torrent-title/-/parse-torrent-title-1.4.0.tgz", + "integrity": "sha512-/G0rQNeAUmNwB3QtyBJtNDAr1Q95Gg3wgwQ3dbYEkX8tOdkw5XmUS03O3+QqAV5hDNRVMatBG2fIoz+H/UMseQ==" + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", diff --git a/package.json b/package.json index 36d30fa..edcf978 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@radix-ui/react-toast": "^1.2.2", "@radix-ui/react-toggle": "^1.0.3", "@tanstack/react-query": "^5.17.3", + "@vidstack/react": "^1.12.11", "axios": "^1.4.0", "class-variance-authority": "^0.7.0", "classnames": "^2.3.2", @@ -28,8 +29,10 @@ "jotai": "^2.2.2", "js-cookie": "^3.0.5", "lucide-react": "^0.263.0", + "media-icons": "^1.1.5", "next": "^14.2.7", "node-html-parser": "^6.1.5", + "parse-torrent-title": "^1.4.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-modal-promise": "^1.0.2", diff --git a/providers/Theme.tsx b/providers/Theme.tsx index 9581731..40fc20b 100644 --- a/providers/Theme.tsx +++ b/providers/Theme.tsx @@ -21,7 +21,7 @@ const Provider: FC = ({ children, theme: initialTheme }) => { return setTheme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); } - document.documentElement.setAttribute('class', theme); + document.documentElement.setAttribute('data-mode', theme); Cookies.set('theme', theme); }, [theme, setTheme]); diff --git a/styles/index.css b/styles/index.css index ea07e3c..0dfa5fd 100644 --- a/styles/index.css +++ b/styles/index.css @@ -39,7 +39,7 @@ --radius: 0.5rem; } - .dark { + [data-mode='dark'] { --background: 222.2 84% 4.9%; --gradient-color: 222.2 84% 4.9%, 0 0% 0%; --foreground: 210 40% 98%; diff --git a/tailwind.config.js b/tailwind.config.js index e7a1ddf..7c52820 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - darkMode: ['class'], + darkMode: ['selector', '[data-mode="dark"]'], content: ['./pages/**/*.{ts,tsx}', './components/**/*.{ts,tsx}', './app/**/*.{ts,tsx}', './src/**/*.{ts,tsx}'], theme: { container: { diff --git a/types.d.ts b/types.d.ts index 8087b03..e879456 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,4 +1,4 @@ -type Theme = 'light' | 'dark'; +type Theme = 'light' | 'dark' | 'system'; interface TMDBPagination { page: number; @@ -82,6 +82,7 @@ interface Person { interface Actor extends Person { character: string; + photoUrl: string; } interface AggregatedActor extends Person { @@ -114,10 +115,15 @@ interface IDName { interface Torrent { id: string; title: string; + originalTitle?: string; seeders: number; size: string; magnet: string; - type: 'web' | 'bluray'; + quality?: string; + source?: string; + codec?: string; + container?: string; + year?: string; } interface Source { @@ -134,11 +140,27 @@ interface Video extends Source { subtitles: Subtitles[]; } -interface ExternalIDS { +interface Stream { + title: string; + category: string; + poster: string; + timestamp: number; + name: string; + hash: string; + stat: number; + stat_string: string; + torrent_size: number; + total_peers: number; + pending_peers: number; + active_peers: number; + half_open_peers: number; + bytes_written: number; + bytes_read: number; + file_stats: FileStat[]; +} + +interface FileStat { id: number; - imdb_id: string; - wikidata_id: string; - facebook_id: string; - instagram_id: string; - twitter_id: string; + path: string; + length: number; }
+ {Object.values(providers).map((provider) => ( @@ -77,35 +80,42 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: