Release v0.2.0 #74
|
@ -1,6 +1,6 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { XVideosCategories } from '@/meta/settings';
|
import { Cookies, XVideosCategories } from '@/meta/settings';
|
||||||
|
|
||||||
import css from './Category.module.scss'
|
import css from './Category.module.scss'
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ const Category: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
const { labels } = props
|
const { labels } = props
|
||||||
|
|
||||||
const [cookies] = useCookies(['category']);
|
const [cookies] = useCookies([Cookies.category]);
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
|
const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
const value = event.target.value;
|
const value = event.target.value;
|
||||||
|
|
||||||
await setCookie('category', value)
|
await setCookie(Cookies.category, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { Platforms } from '@/meta/settings';
|
import { Cookies, Platforms } from '@/meta/settings';
|
||||||
|
|
||||||
import css from './Platform.module.scss'
|
import css from './Platform.module.scss'
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ const Platform: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
const { labels } = props
|
const { labels } = props
|
||||||
|
|
||||||
const [cookies] = useCookies(['platform']);
|
const [cookies] = useCookies([Cookies.platform]);
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
|
const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
const value = event.target.value;
|
const value = event.target.value;
|
||||||
|
|
||||||
await setCookie('platform', value)
|
await setCookie(Cookies.platform, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { TbMoon, TbSun } from 'react-icons/tb';
|
import { TbMoon, TbSun } from 'react-icons/tb';
|
||||||
import { DEFAULT_THEME, Themes } from '@/meta/settings';
|
import { Cookies, DEFAULT_THEME, Themes } from '@/meta/settings';
|
||||||
|
|
||||||
import Icon from '../Icon';
|
import Icon from '../Icon';
|
||||||
import { setCookie } from '@/utils/cookies/write';
|
import { setCookie } from '@/utils/cookies/write';
|
||||||
|
@ -11,13 +11,13 @@ import { useCookies } from 'react-cookie';
|
||||||
|
|
||||||
const Theme: React.FC = () => {
|
const Theme: React.FC = () => {
|
||||||
|
|
||||||
const [cookies] = useCookies(['theme']);
|
const [cookies] = useCookies([Cookies.theme]);
|
||||||
|
|
||||||
const theme = cookies.theme ?? DEFAULT_THEME
|
const theme = cookies.theme ?? DEFAULT_THEME
|
||||||
|
|
||||||
const handleClick = async () => {
|
const handleClick = async () => {
|
||||||
const newTheme = theme == Themes.dark ? Themes.light : Themes.dark
|
const newTheme = theme == Themes.dark ? Themes.light : Themes.dark
|
||||||
await setCookie('theme', newTheme)
|
await setCookie(Cookies.theme, newTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
export const XVIDEOS_BASE_URL: string = "https://www.xvideos.com"
|
export const XVIDEOS_BASE_URL: string = "https://www.xvideos.com"
|
||||||
|
export const XVIDEOS_BASE_URL_GAY: string = "https://www.xvideos.com/gay"
|
||||||
|
export const XVIDEOS_BASE_URL_TRANS: string = "https://www.xvideos.com/shemale"
|
|
@ -1,8 +1,20 @@
|
||||||
|
export enum Cookies {
|
||||||
|
theme= 'theme',
|
||||||
|
category= 'category',
|
||||||
|
platform= 'platform'
|
||||||
|
}
|
||||||
|
|
||||||
export enum Platforms {
|
export enum Platforms {
|
||||||
xvideos= 'xvideos',
|
xvideos= 'xvideos',
|
||||||
xnxx= 'xnxx'
|
xnxx= 'xnxx'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum XVideosCatQueryMap {
|
||||||
|
etero= 'straight',
|
||||||
|
gay= 'gay',
|
||||||
|
trans= 'shemale'
|
||||||
|
}
|
||||||
|
|
||||||
export enum XVideosCategories {
|
export enum XVideosCategories {
|
||||||
etero= 'etero',
|
etero= 'etero',
|
||||||
gay= 'gay',
|
gay= 'gay',
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { XVIDEOS_BASE_URL } from '@/constants/urls';
|
|
||||||
import { GalleryData } from '@/meta/data';
|
import { GalleryData } from '@/meta/data';
|
||||||
import axios, { AxiosError } from 'axios';
|
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';
|
||||||
|
|
||||||
interface FetchParams {
|
interface FetchParams {
|
||||||
baseUrl?: string
|
baseUrl?: string
|
||||||
|
@ -16,7 +16,7 @@ export const fetchGalleryData = async (params?: FetchParams): Promise<GalleryDat
|
||||||
|
|
||||||
const reqHeaders = getHeaders()
|
const reqHeaders = getHeaders()
|
||||||
|
|
||||||
const queryUrl = `${(params && params.baseUrl) ?? XVIDEOS_BASE_URL}${params && params.query ? '/?k=' + params.query : ''}`
|
const queryUrl = await getXVideosQueryUrl(params?.query)
|
||||||
|
|
||||||
await axios.get(queryUrl, reqHeaders)
|
await axios.get(queryUrl, reqHeaders)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { XVIDEOS_BASE_URL, XVIDEOS_BASE_URL_GAY, XVIDEOS_BASE_URL_TRANS } from '@/constants/urls';
|
||||||
|
import { Cookies, XVideosCatQueryMap, XVideosCategories } from '@/meta/settings';
|
||||||
|
import { getCookie } from '@/utils/cookies/read';
|
||||||
|
|
||||||
|
export const getXVideosQueryUrl = async (query?: string) => {
|
||||||
|
|
||||||
|
const category = await getCookie(Cookies.category)
|
||||||
|
|
||||||
|
if (!category && !query) {
|
||||||
|
return XVIDEOS_BASE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!category && query) {
|
||||||
|
return `${XVIDEOS_BASE_URL}/?k=${query}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category && !Object.values(XVideosCategories).includes(category.value as XVideosCategories)) {
|
||||||
|
return XVIDEOS_BASE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category && !query) {
|
||||||
|
switch (category.value) {
|
||||||
|
case XVideosCategories.etero:
|
||||||
|
return XVIDEOS_BASE_URL
|
||||||
|
case XVideosCategories.gay:
|
||||||
|
return XVIDEOS_BASE_URL_GAY
|
||||||
|
case XVideosCategories.trans:
|
||||||
|
return XVIDEOS_BASE_URL_TRANS
|
||||||
|
default:
|
||||||
|
return XVIDEOS_BASE_URL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category && query) {
|
||||||
|
return `${XVIDEOS_BASE_URL}/?k=${query}&typef=${XVideosCatQueryMap[category.value as XVideosCategories]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return XVIDEOS_BASE_URL
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue