From b5cd3f5c7962136946b2ad464b354ca3909f0fc4 Mon Sep 17 00:00:00 2001 From: Rohithk <67067796+Rohithk2003@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:42:05 +0530 Subject: [PATCH] improved movie page --- Common/TorrentList.js | 337 +++++++++++++++++++------------------- components/Collection.js | 8 +- components/FilmHeading.js | 13 +- components/Layout.js | 2 +- pages/api/movie/[id].js | 4 - pages/f.js | 8 + pages/movie/[id].js | 4 +- pages/play/movies.js | 127 ++++++++++++-- utils/index.js | 54 +++--- 9 files changed, 331 insertions(+), 226 deletions(-) create mode 100644 pages/f.js diff --git a/Common/TorrentList.js b/Common/TorrentList.js index 0c07874..1f964a5 100644 --- a/Common/TorrentList.js +++ b/Common/TorrentList.js @@ -1,184 +1,187 @@ import moment from 'moment' -import { useRouter } from 'next/router' +import {useRouter} from 'next/router' import React from 'react' import Modal from 'react-modal' -import { formatBytes } from './CardExpanded' +import {formatBytes} from './CardExpanded' -import DataTable, { createTheme } from 'react-data-table-component' -import { useTheme } from 'next-themes' +import DataTable, {createTheme} from 'react-data-table-component' +import {useTheme} from 'next-themes' -const TorrentList = ({ setisTorrent, torrent_list, runtime }) => { - const { theme, settheme } = useTheme() - const router = useRouter() +const TorrentList = ({setisTorrent, torrent_list, runtime}) => { + const theme = useTheme() + const router = useRouter() - const customStyles = { - content: { - top: '50%', - left: '50%', - right: 'auto', - bottom: 'auto', - marginRight: '-50%', - transform: 'translate(-50%, -50%)', - background: '#171e30', - maxHeight: '700px', - maxWidth: '1500px', - border: '0px', - width: '100%', - borderColor: '#454851', - }, - } + const customStyles = { + content: { + top: '50%', + left: '50%', + right: 'auto', + bottom: 'auto', + marginRight: '-50%', + transform: 'translate(-50%, -50%)', + background: '#171e30', + maxHeight: '700px', + maxWidth: '1500px', + border: '0px', + width: '100%', + borderColor: '#454851', + }, + } - const qualityRegex = /(4K|720p|1080p|2160p|720P|360P|360p|1080P)/i + const qualityRegex = /(4K|720p|1080p|2160p|720P|360P|360p|1080P)/i - const columns = [ - { - name: 'Name', - selector: row => row.name, - sortable: true, - }, - { - name: 'Action', + const columns = [ + { + name: 'Name', + selector: row => row.name, + sortable: true, + }, + { + name: 'Action', - cell: (row, index) => { - let slug = row?.name - .toLowerCase() - .trim() - .replace(/[^\w\s-]/g, '') - .replace(/[\s_-]+/g, '-') - .replace(/^-+|-+$/g, '') + cell: (row, index) => { + let slug = row?.name + .toLowerCase() + .trim() + .replace(/[^\w\s-]/g, '') + .replace(/[\s_-]+/g, '-') + .replace(/^-+|-+$/g, '') - return ( - router.push(`/post-detail/${row?.eid}/${slug}/`)}> - Download - - ) - }, - width: '8%', - style: { - color: '#296ac8', - cursor: 'pointer', - }, - }, - { - name: 'Category', - selector: row => row.category_str, - width: '8%', - sortable: true, - }, - { - name: 'Res', - selector: row => - row.name.match(qualityRegex) ? row.name.match(qualityRegex)[0] : '', - width: '6%', - sortable: true, - sortFunction: (a, b) => { - function compareQuality(a, b) { - if (a && b) { - const regex = /(\d+)p/ - const qualityA = parseInt( - a.name.match(qualityRegex) - ? a.name.match(qualityRegex)[0]?.match(regex) - : '' - ) - const qualityB = parseInt( - b.name.match(qualityRegex) - ? b.name.match(qualityRegex)[0]?.match(regex) - : '' - ) - return qualityA - qualityB - } - } + return ( + router.push(`/post-detail/${row?.eid}/${slug}/`)}> + Download + + ) + }, + width: '8%', + style: { + color: '#296ac8', + cursor: 'pointer', + }, + }, + { + name: 'Category', + selector: row => row.category_str, + width: '8%', + sortable: true, + }, + { + name: 'Res', + selector: row => + row.name.match(qualityRegex) ? row.name.match(qualityRegex)[0] : '', + width: '6%', + sortable: true, + sortFunction: (a, b) => { + function compareQuality(a, b) { + if (a && b) { + const regex = /(\d+)p/ + const qualityA = parseInt( + a.name.match(qualityRegex) + ? a.name.match(qualityRegex)[0]?.match(regex) + : '' + ) + const qualityB = parseInt( + b.name.match(qualityRegex) + ? b.name.match(qualityRegex)[0]?.match(regex) + : '' + ) + return qualityA - qualityB + } + } - return compareQuality(a, b) - }, - }, - { - name: 'Date', - selector: row => moment(row?.last_checked).format('DD-MM-YYYY'), - width: '9%', - sortable: true, - }, - { - name: 'Runtime', - selector: row => moment.utc(runtime * 1000).format('HH:mm:ss'), - width: '9%', - sortable: true, - }, - { - name: 'Size', - selector: row => formatBytes(row?.size), - sortable: true, - width: '7%', - sortFunction: (a, b) => { - return a.size - b.size - }, - }, - { - name: 'S', - selector: row => row?.seeders, - sortable: true, - width: '5%', - style: { - color: '#00FF00', - }, - }, - { - name: 'L', - selector: row => row.leechers, - sortable: true, - width: '5%', - style: { - color: '#dd0c0e', - }, - }, - ] - createTheme('dark', { - background: { - default: 'transparent', - }, - }) + return compareQuality(a, b) + }, + }, + { + name: 'Date', + selector: row => moment(row?.last_checked).format('DD-MM-YYYY'), + width: '9%', + sortable: true, + }, + { + name: 'Runtime', + selector: row => moment.utc(runtime * 1000).format('HH:mm:ss'), + width: '9%', + sortable: true, + }, + { + name: 'Size', + selector: row => formatBytes(row?.size), + sortable: true, + width: '7%', + sortFunction: (a, b) => { + return a.size - b.size + }, + }, + { + name: 'S | L', + cell: (row, index) => { + let l = row?.leechers + let s = row?.seeders + return ( + + {l} | {s} + + ) + }, + sortable: true, + sortFunction: (a, b) => { + return a?.leechers - b?.leechers + }, + width: '8%', + style: { + color: '#00FF00', + }, + }, - const customCss = { - headCells: { - style: { - fontSize: '14px', - fontWeight: '700', - color: theme === 'dark' ? '#C2D8D3' : '#000000', - }, - }, - } + ] + createTheme('dark', { + background: { + default: 'transparent', + }, + }) - console.log('torrent_list', torrent_list) + const customCss = { + headCells: { + style: { + fontSize: '14px', + fontWeight: '700', + color: theme === 'dark' ? '#C2D8D3' : '#000000', + }, + }, + } - createTheme('dark', { - background: { - default: 'transparent', - }, - }) + console.log('torrent_list', torrent_list) - return ( - <> - setisTorrent(false)}> - {' '} - {torrent_list.length > 0 ? ( - - ) : ( -
-

Sorry Torrent Not Available Try after some days !!!

-
- )} - {/* { + createTheme('dark', { + background: { + default: 'transparent', + }, + }) + + return ( + <> + setisTorrent(false)}> + {' '} + {torrent_list.length > 0 ? ( + + ) : ( +
+

Sorry Torrent Not Available Try after some days !!!

+
+ )} + {/* {          torrent_list.length>0? @@ -282,9 +285,9 @@ const TorrentList = ({ setisTorrent, torrent_list, runtime }) => {               } */} -
- - ) +
+ + ) } export default TorrentList diff --git a/components/Collection.js b/components/Collection.js index d747627..9aa5d10 100644 --- a/components/Collection.js +++ b/components/Collection.js @@ -42,13 +42,7 @@ export default function Collection({ ? 'h-scroll relative flex gap-x-4 overflow-x-scroll sm:gap-x-10 2xs:mt-2' : 'card-collection-wrapper' }> - { isTrending && -
-
- > -
-
- } + {renderResults( sliceArray(data.results || [], limit), Component, diff --git a/components/FilmHeading.js b/components/FilmHeading.js index f577a4c..f34d95b 100644 --- a/components/FilmHeading.js +++ b/components/FilmHeading.js @@ -1,10 +1,17 @@ -export default function FilmHeading({ tagline, title }) { +export default function FilmHeading({ tagline, title ,from}) { return ( -
+ from === "movie"? +

{title}

{tagline}

-
+
: +
+

{title}

+

+ {tagline} +

+
) } diff --git a/components/Layout.js b/components/Layout.js index 5b5ecbe..174c41a 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -7,7 +7,7 @@ export default function Layout({ children }) {
-
+
{children}
diff --git a/pages/api/movie/[id].js b/pages/api/movie/[id].js index 5042cef..a655468 100644 --- a/pages/api/movie/[id].js +++ b/pages/api/movie/[id].js @@ -7,10 +7,6 @@ export default async function handler(req, res) { const response = await fetch(getMovieDetail(id)) const response2 = await fetch(getMovieCasts(id)) - - - - const data = await response.json() const data2 = await response2.json() const response3 = await fetch(getLinkByIMDB(data.imdb_id)); diff --git a/pages/f.js b/pages/f.js new file mode 100644 index 0000000..3788e0f --- /dev/null +++ b/pages/f.js @@ -0,0 +1,8 @@ +export default function Fdd(){ + return( + <> +
helllo
+ + + ) +} \ No newline at end of file diff --git a/pages/movie/[id].js b/pages/movie/[id].js index d8da4d4..f2e70f2 100644 --- a/pages/movie/[id].js +++ b/pages/movie/[id].js @@ -129,7 +129,7 @@ export function renderRating(rating) { } } -function renderLength(runtime) { +export function renderLength(runtime) { if (runtime !== 0 && runtime !== undefined) { return runtime + ' min?.' } else { @@ -145,7 +145,7 @@ export function renderLanguage(languages) { } } -function renderYear(year) { +export function renderYear(year) { if (!year) { return 'N/A' } else { diff --git a/pages/play/movies.js b/pages/play/movies.js index 746ee8f..f46865c 100644 --- a/pages/play/movies.js +++ b/pages/play/movies.js @@ -1,20 +1,117 @@ -import React from 'react' -import { useRouter } from 'next/router'; +import React, {useState} from 'react' +import {useRouter} from 'next/router'; import Head from 'next/head' +import useSWR from "swr"; +import FilmGenres from '../../components/FilmGenres' +import FilmHeading from '../../components/FilmHeading' +import FilmImage from '../../components/FilmImage' +import FilmInfo from '../../components/FilmInfo' +import FilmRating from '../../components/FilmRating' +import FilmSynopsis from '../../components/FilmSynopsis' +import {renderLanguage, renderLength, renderRating, renderStatus, renderYear} from "../movie/[id]"; +import {AiOutlineExpand} from "react-icons/ai"; + +const servers_ = [ + { + servername: "Vidsrc.me", link: "https://vidsrc.me/embed/movie?", + }, + { + servername: "Vidsrc.to", link: "https://vidsrc.to/embed/movie/" + }, + { + servername: "Moviesapi.club", link: "https://moviesapi.club/movie/" + } +] +const fetcher = (...args) => fetch(...args).then((res) => res.json()) const Movies = () => { const router = useRouter() - const { id,tmdb} = router.query; - - return ( - <> - - Play Movies | Yaps - - - - - ) -} + const {id, tmdb} = router.query; + const me = tmdb ? `tmdb=${tmdb}` : `imdb=${id}` + const to = tmdb ? `${tmdb}` : `${id}` + const [videoServer, setVideoServer] = useState('') + const {data, error} = useSWR(`/api/movie/${id}`, fetcher) + const [MovieDetailsHidden, setMovieDetailsHidden] = useState(false) -export default Movies + return ( + <> + + Play Movies | Yaps + +
+
+ +
+
setMovieDetailsHidden(!MovieDetailsHidden)} + className={"flex flex-row gap-1 items-center hover:text-orange-500 transition duration-300 ease-in-out hover:cursor-pointer"}> + + Expand +
+
+
+
+
+ {`You are watching `} +
{data ? data.imdb.imdb.name : ""}
+
If current server doesn't work please try other servers beside.
+
+
+
+ {servers_.map((server, index) => { + return ( +
{ + if (server.servername === "Vidsrc.me") + setVideoServer(server.link + me) + else if (server.servername === "Vidsrc.to") + setVideoServer(server.link + to) + else + setVideoServer(server.link + data?.imdb.imdb.tmdb_id); + } + } + className={"dark:bg-app-semi-dark-blue dark:text-white hover:scale-110 hover:cursor-pointer transition duration-300 ease-in-out bg-app-shady-white rounded p-3 w-[8em] text-center h-8"} + key={index}> + {server.servername} +
+ ) + })} +
+
+
+
+
+
+
+ +
+ + + + + +
+
+
+
+ + ) +} +export default Movies; diff --git a/utils/index.js b/utils/index.js index 986efec..06d739e 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,24 +1,23 @@ -import { v4 as uuidv4 } from 'uuid' +import {v4 as uuidv4} from 'uuid' export const TMDB_ENDPOINT = "https://api.themoviedb.org/3" export const TMDB_API_KEY = "d0e6107be30f2a3cb0a34ad2a90ceb6f" export const TMDB_IMAGE_ENDPOINT = 'https://image.tmdb.org/t/p/original' - export const pathToSearchAll = '/search/' export const pathToSearchMovie = '/search/movie/' export const pathToSearchTV = '/search/tv/' -export const fetcher = url => fetch(url).then(res =>{ +export const fetcher = url => fetch(url).then(res => { - return res.json() - }) + return res.json() +}) export const shimmer = (w, h) => ` - + @@ -33,30 +32,31 @@ export const shimmer = (w, h) => ` ` export const toBase64 = str => - typeof window === 'undefined' - ? Buffer.from(str).toString('base64') - : window.btoa(str) + typeof window === 'undefined' + ? Buffer.from(str).toString('base64') + : window.btoa(str) export const renderResults = (array, Component, media_type) => { - return array.map(item => ( - - )) + console.log(array) + return array.map(item => ( + + )) } export const sliceArray = (arr, limit) => { - return arr.slice(0, limit) + return arr.slice(0, limit) }