Release v0.2.0 #74

Merged
lamacchinadesiderante merged 24 commits from develop into main 2024-05-13 18:07:51 +00:00
5 changed files with 22 additions and 6 deletions
Showing only changes of commit a58cc663d6 - Show all commits

View File

@ -9,12 +9,19 @@ import { decodeVideoUrlPath } from '@/utils/string';
import { fetchVideoData } from '@/utils/scrape/xvideos/video'; import { fetchVideoData } from '@/utils/scrape/xvideos/video';
import { useLocale } from 'next-intl'; import { useLocale } from 'next-intl';
import { Platforms } from '@/meta/settings';
export default async function VideoPage({ params }: { params: { id: string } }) { export default async function VideoPage({ params }: { params: { platform: Platforms, id: string } }) {
const { platform, id } = params
const locale = useLocale() const locale = useLocale()
const decodedId = decodeVideoUrlPath(params.id) if (!platform || !Object.keys(Platforms).includes(platform)) {
redirect(`/${locale}/404`)
}
const decodedId = decodeVideoUrlPath(id)
const [data, related] = await fetchVideoData(decodedId) const [data, related] = await fetchVideoData(decodedId)
@ -23,6 +30,6 @@ export default async function VideoPage({ params }: { params: { id: string } })
} }
return <Layout> return <Layout>
<Video id={params.id} data={data} related={related}/> <Video id={id} data={data} related={related}/>
</Layout> </Layout>
} }

View File

@ -9,25 +9,28 @@ import classNames from 'classnames';
import Link from 'next/link' import Link from 'next/link'
import style from './Thumbnail.module.scss' import style from './Thumbnail.module.scss'
import { encodeVideoUrlPath } from '@/utils/string'; import { encodeVideoUrlPath } from '@/utils/string';
import { Platforms } from '@/meta/settings';
interface Props { interface Props {
locale: string locale: string
videoUrl: string videoUrl: string
imgUrl: string imgUrl: string
platform: Platforms
text: string text: string
show: boolean show: boolean
} }
const Thumbnail: React.FC<Props> = (props) => { const Thumbnail: React.FC<Props> = (props) => {
const { locale, videoUrl, imgUrl, text, show } = props const { locale, platform, videoUrl, imgUrl, text, show } = props
const encodedUri = encodeVideoUrlPath(videoUrl) const encodedUri = encodeVideoUrlPath(videoUrl)
return ( return (
<div className={classNames(style.thumbnailContainer, { [style.show]: show } )}> <div className={classNames(style.thumbnailContainer, { [style.show]: show } )}>
<Link href={`/${locale}/video/${encodedUri}`}> <Link href={`/${locale}/video/${platform}/${encodedUri}`}>
<Img className={style.image} src={imgUrl} unloader={<div className={style.imgPlaceholder}></div>} /> <Img className={style.image} src={imgUrl} unloader={<div className={style.imgPlaceholder}></div>} />
<div className={style.text}>{text}</div> <div className={style.text}>{text}</div>
</Link> </Link>

View File

@ -27,6 +27,7 @@ const Gallery: React.FC<Props> = (props) => {
key={key} key={key}
imgUrl={elem.imgUrl} imgUrl={elem.imgUrl}
videoUrl={elem.videoUrl} videoUrl={elem.videoUrl}
platform={elem.platform}
text={elem.text} text={elem.text}
locale={locale} /> locale={locale} />
})} })}

View File

@ -1,7 +1,10 @@
import { Platforms } from "./settings"
export interface GalleryData { export interface GalleryData {
videoUrl: string videoUrl: string
imgUrl: string imgUrl: string
text: string text: string
platform: Platforms
} }
export interface VideoData { export interface VideoData {

View File

@ -4,6 +4,7 @@ import axios, { AxiosError } from 'axios';
import * as cheerio from "cheerio"; import * as cheerio from "cheerio";
import { getHeaders } from '../headers'; import { getHeaders } from '../headers';
import { getXVideosQueryUrl } from './url'; import { getXVideosQueryUrl } from './url';
import { Platforms } from '@/meta/settings';
interface FetchParams { interface FetchParams {
baseUrl?: string baseUrl?: string
@ -37,7 +38,8 @@ export const fetchGalleryData = async (params?: FetchParams): Promise<GalleryDat
videoUrl && imgUrl && text && data.push({ videoUrl && imgUrl && text && data.push({
videoUrl, videoUrl,
imgUrl, imgUrl,
text text,
platform: Platforms.xvideos
}) })
}) })