Compare commits

...

12 Commits
v0.4.1 ... main

Author SHA1 Message Date
lamacchinadesiderante e981b174e3 Merge pull request 'Release v0.4.1' (#118) from develop into main
Reviewed-on: #118
2024-06-09 17:45:37 +00:00
lamacchinadesiderante 1a8c70cbee Merge pull request 'Release v0.4.1 : Fix issue with slashes on encoded url strings' (#117) from v0.4.1/fix-encoding-broken-url-issues into develop
Reviewed-on: #117
2024-05-29 19:35:23 +00:00
lamacchinadesiderante a0d1e30eb9 fix issue with slashes on encoded url strings 2024-05-29 21:27:10 +02:00
lamacchinadesiderante af8cbefdf9 Merge pull request 'Add XHamster info in README' (#116) from v0.4.1/xhamster-update-readme into develop
Reviewed-on: #116
2024-05-28 20:47:54 +00:00
La macchina desiderante 3fb99b877c add XHamster info in README 2024-05-28 22:46:47 +02:00
lamacchinadesiderante f311b64d51 Merge pull request 'Release v0.4.1: Refactor platforms and orientation' (#115) from v0.4.1/refactor-platforms-and-orientation into develop
Reviewed-on: #115
2024-05-28 20:23:44 +00:00
La macchina desiderante d41e3a91c2 resolve o/c violation inside Platform component 2024-05-28 22:20:05 +02:00
La macchina desiderante 6a8e433367 resolve o/c violation inside Orientation component 2024-05-28 22:10:35 +02:00
lamacchinadesiderante 97dd3caa26 Merge pull request 'v0.4.1/add-xhamster-support' (#114) from v0.4.1/add-xhamster-support into develop
Reviewed-on: #114
2024-05-28 19:44:14 +00:00
La macchina desiderante 9ede9a6b9b add xhamster video/related scrape 2024-05-28 21:40:32 +02:00
La macchina desiderante 1905707b92 add xhamster gallery search 2024-05-28 20:28:02 +02:00
La macchina desiderante 291c6efe55 add xhamster base structure 2024-05-28 20:10:17 +02:00
13 changed files with 274 additions and 44 deletions

View File

@ -9,6 +9,7 @@ Proxy Raye is an alternative front-end for adult websites. Watch videos on a cle
- PornHub (experimental) - PornHub (experimental)
- YouPorn - YouPorn
- RedTube - RedTube
- XHamster
### How to switch between platforms ### How to switch between platforms
@ -131,7 +132,7 @@ Due to Vercel's *serverless* nature (which makes every request to XVideos and ot
You can self host the project on your local server via docker-compose and reverse-proxy exposed port to nginx. You can self host the project on your local server via docker-compose and reverse-proxy exposed port to nginx.
### Disabling platforms (both Vercel / Self-host) # Disabling platforms
For several reason you might want to disable some platforms. You can do it by adding `DISABLED_PLATFORMS` environment variable. For several reason you might want to disable some platforms. You can do it by adding `DISABLED_PLATFORMS` environment variable.

View File

@ -1,6 +1,6 @@
{ {
"name": "proxyraye-next", "name": "proxyraye-next",
"version": "0.4.0", "version": "0.4.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@ -1,6 +1,6 @@
'use client' 'use client'
import { Cookies, Platforms, XVideosOrientations, PornHubOrientations, YouPornOrientations, RedTubeOrientations } from '@/meta/settings'; import { Cookies, OrientationMapper, Platforms, XVideosOrientations } from '@/meta/settings';
import css from './Orientation.module.scss' import css from './Orientation.module.scss'
@ -17,19 +17,7 @@ interface Props {
} }
const getOrientations = (platform: Platforms):Object => { const getOrientations = (platform: Platforms):Object => {
if ([Platforms.xnxx, Platforms.xvideos].includes(platform)) { return OrientationMapper[platform];
return XVideosOrientations
}
if([Platforms.youporn].includes(platform)) {
return YouPornOrientations
}
if([Platforms.redtube].includes(platform)) {
return RedTubeOrientations
}
return PornHubOrientations
} }
const Orientation: React.FC<Props> = (props) => { const Orientation: React.FC<Props> = (props) => {
@ -38,7 +26,7 @@ const Orientation: React.FC<Props> = (props) => {
const [cookies] = useCookies([Cookies.orientation, Cookies.platform]); const [cookies] = useCookies([Cookies.orientation, Cookies.platform]);
const orientationsList = cookies.platform ? getOrientations(cookies.platform ) : XVideosOrientations const orientationsList = cookies.platform ? getOrientations(cookies.platform) : XVideosOrientations
const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => { const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
const value = event.target.value; const value = event.target.value;

View File

@ -1,6 +1,6 @@
'use client' 'use client'
import { Cookies, Platforms, PornHubOrientations, RedTubeOrientations, XVideosOrientations, YouPornOrientations } from '@/meta/settings'; import { Cookies, OrientationMapper, Platforms } from '@/meta/settings';
import css from './Platform.module.scss' import css from './Platform.module.scss'
@ -18,23 +18,8 @@ interface Props {
} }
const mapOrientationToPlatform = (platform: string, orientation: string): string | undefined => { const mapOrientationToPlatform = (platform: string, orientation: string): string | undefined => {
const orientations = OrientationMapper[platform as Platforms]
if ([String(Platforms.xnxx), String(Platforms.xvideos)].includes(platform)) { return Object.keys(orientations).includes(orientation) ? orientation : String(Object.keys(orientations)[0])
return Object.keys(XVideosOrientations).includes(orientation) ? orientation : String(XVideosOrientations.etero)
}
if ([String(Platforms.pornhub)].includes(platform)) {
return Object.keys(PornHubOrientations).includes(orientation) ? orientation : String(PornHubOrientations.generic)
}
if ([String(Platforms.redtube)].includes(platform)) {
return Object.keys(RedTubeOrientations).includes(orientation) ? orientation : String(RedTubeOrientations.etero)
}
if ([String(Platforms.youporn)].includes(platform)) {
return String(YouPornOrientations.generic)
}
} }
const Platform: React.FC<Props> = (props) => { const Platform: React.FC<Props> = (props) => {

View File

@ -15,4 +15,7 @@ export const DEFAULT_YOUPORN_VIDEO_EXPIRY = { EX: EX_HOURLY };
export const DEFAULT_REDTUBE_GALLERY_EXPIRY = { EX: EX_HOURLY }; export const DEFAULT_REDTUBE_GALLERY_EXPIRY = { EX: EX_HOURLY };
export const DEFAULT_REDTUBE_VIDEO_EXPIRY = { EX: EX_HOURLY }; export const DEFAULT_REDTUBE_VIDEO_EXPIRY = { EX: EX_HOURLY };
export const DEFAULT_XHAMSTER_GALLERY_EXPIRY = { EX: EX_HOURLY };
export const DEFAULT_XHAMSTER_VIDEO_EXPIRY = { EX: EX_HOURLY };
export const DEFAULT_RELATED_VIDEO_KEY_PATH = '/related/' export const DEFAULT_RELATED_VIDEO_KEY_PATH = '/related/'

View File

@ -37,4 +37,16 @@ export const REDTUBE_BASE_URL_GAY: string = 'https://www.redtube.com/gay'
export const REDTUBE_BASE_URL_TRANS: string = 'https://www.redtube.com/redtube/transgender' export const REDTUBE_BASE_URL_TRANS: string = 'https://www.redtube.com/redtube/transgender'
export const REDTUBE_BASE_SEARCH: string = 'https://www.redtube.com/?search=' export const REDTUBE_BASE_SEARCH: string = 'https://www.redtube.com/?search='
export const REDTUBE_BASE_GAY_SEARCH: string = 'https://www.redtube.com/gay?search=' export const REDTUBE_BASE_GAY_SEARCH: string = 'https://www.redtube.com/gay?search='
// XHAMSTER
export const XHAMSTER_BASE_URL = 'https://xhamster.com'
export const XHAMSTER_BASE_URL_VIDEOS = 'https://xhamster.com/videos'
export const XHAMSTER_BASE_URL_ETERO = 'https://xhamster.com/newest'
export const XHAMSTER_BASE_URL_GAY = 'https://xhamster.com/gay/newest'
export const XHAMSTER_BASE_URL_TRANS = 'https://xhamster.com/shemale/newest'
export const XHAMSTER_BASE_SEARCH = 'https://xhamster.com/search/'
export const XHAMSTER_BASE_SEARCH_GAY = 'https://xhamster.com/gay/search/'
export const XHAMSTER_BASE_SEARCH_TRANS = 'https://xhamster.com/shemale/search/'

View File

@ -9,7 +9,8 @@ export enum Platforms {
xnxx= 'xnxx', xnxx= 'xnxx',
pornhub= 'pornhub', pornhub= 'pornhub',
youporn= 'youporn', youporn= 'youporn',
redtube= 'redtube' redtube= 'redtube',
xhamster= 'xhamster'
} }
export enum XVideosCatQueryMap { export enum XVideosCatQueryMap {
@ -39,6 +40,12 @@ export enum RedTubeOrientations {
trans= 'trans' trans= 'trans'
} }
export enum XHamsterOrientations {
etero= 'etero',
gay= 'gay',
trans= 'trans'
}
export enum Themes { export enum Themes {
light= 'light', light= 'light',
dark= 'dark', dark= 'dark',
@ -51,3 +58,12 @@ export interface LangOption {
label: string; label: string;
code: string; code: string;
} }
export const OrientationMapper = {
[Platforms.xvideos]: XVideosOrientations,
[Platforms.xnxx]: XVideosOrientations,
[Platforms.pornhub]: PornHubOrientations,
[Platforms.youporn]: YouPornOrientations,
[Platforms.redtube]: RedTubeOrientations,
[Platforms.xhamster]: XHamsterOrientations
}

View File

@ -7,13 +7,15 @@ import { XNXXAgent } from "./scrape/xnxx/agent";
import { PornHubAgent } from "./scrape/pornhub/agent"; import { PornHubAgent } from "./scrape/pornhub/agent";
import { YouPornAgent } from "./scrape/youporn/agent"; import { YouPornAgent } from "./scrape/youporn/agent";
import { RedTubeAgent } from "./scrape/redtube/agent"; import { RedTubeAgent } from "./scrape/redtube/agent";
import { XHamsterAgent } from "./scrape/xhamster/agent";
const AgentMapper = { const AgentMapper = {
[Platforms.xvideos]: XVideosAgent, [Platforms.xvideos]: XVideosAgent,
[Platforms.xnxx]: XNXXAgent, [Platforms.xnxx]: XNXXAgent,
[Platforms.pornhub]: PornHubAgent, [Platforms.pornhub]: PornHubAgent,
[Platforms.youporn]: YouPornAgent, [Platforms.youporn]: YouPornAgent,
[Platforms.redtube]: RedTubeAgent [Platforms.redtube]: RedTubeAgent,
[Platforms.xhamster]: XHamsterAgent
} }
export class VideoAgent { export class VideoAgent {

View File

@ -0,0 +1,15 @@
import { FetchParams, GalleryData, VideoAgent, VideoData } from "@/meta/data";
import { fetchXHamsterGalleryData } from "./gallery";
import { fetchXHamsterVideoData } from "./video";
export class XHamsterAgent implements VideoAgent {
public getGallery = async (params?: FetchParams): Promise<GalleryData[]> => {
return await fetchXHamsterGalleryData(params)
}
public getVideo = async (id: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
return await fetchXHamsterVideoData(id, params)
}
}

View File

@ -0,0 +1,62 @@
import { XHAMSTER_BASE_URL, XHAMSTER_BASE_URL_VIDEOS } from "@/constants/urls";
import { FetchParams, GalleryData } from "@/meta/data";
import { getHeaders } from "../common/headers";
import { getXHamsterQueryUrl } from "./url";
import { getDataFromRedis, storeDataIntoRedis } from "@/redis/client";
import * as cheerio from "cheerio";
import axios, { AxiosError } from "axios";
import { DEFAULT_XHAMSTER_GALLERY_EXPIRY } from "@/constants/redis";
import { Platforms } from "@/meta/settings";
export const fetchXHamsterGalleryData = async (params?: FetchParams): Promise<GalleryData[]> => {
let data: GalleryData[] = [];
const reqHeaders = getHeaders(XHAMSTER_BASE_URL)
const queryUrl = await getXHamsterQueryUrl(params?.query)
const cachedData = await getDataFromRedis(queryUrl)
if (cachedData) {
return cachedData as GalleryData[]
}
await axios.get(queryUrl, reqHeaders)
.then(async response => {
const html = response.data;
const $ = cheerio.load(html);
const wrapperId = '.thumb-list .thumb-list__item'
const thumbs = $(wrapperId);
thumbs.map((key, thumb) => {
const videoUrl = $(thumb).find("a.video-thumb__image-container").attr("href")?.replace(XHAMSTER_BASE_URL_VIDEOS, '')
const imgUrl = $(thumb).find("a.video-thumb__image-container img").attr("src")
const text = $(thumb).find("a.video-thumb-info__name").attr("title")
videoUrl && imgUrl && text && data.push({
videoUrl,
imgUrl,
text,
platform: Platforms.xhamster
})
})
if (data.length > 0) {
await storeDataIntoRedis(queryUrl, data, DEFAULT_XHAMSTER_GALLERY_EXPIRY);
}
}).catch((error: AxiosError) => {
// handle errors
});
return data
}

View File

@ -0,0 +1,30 @@
import { XHAMSTER_BASE_SEARCH, XHAMSTER_BASE_SEARCH_GAY, XHAMSTER_BASE_SEARCH_TRANS, XHAMSTER_BASE_URL_ETERO, XHAMSTER_BASE_URL_GAY, XHAMSTER_BASE_URL_TRANS } from "@/constants/urls"
import { Cookies, XHamsterOrientations } from "@/meta/settings"
import { getCookie } from "@/utils/cookies/read"
export const getXHamsterQueryUrl = async (query?: string): Promise<string> => {
const orientation = await getCookie(Cookies.orientation)
if (query) {
if (orientation && orientation.value == XHamsterOrientations.gay) {
return XHAMSTER_BASE_SEARCH_GAY + query + '?revert=orientation'
}
if (orientation && orientation.value == XHamsterOrientations.trans) {
return XHAMSTER_BASE_SEARCH_TRANS + query + '?revert=orientation'
}
return XHAMSTER_BASE_SEARCH + query
} else {
if (orientation && orientation.value == XHamsterOrientations.gay) {
return XHAMSTER_BASE_URL_GAY
}
if (orientation && orientation.value == XHamsterOrientations.trans) {
return XHAMSTER_BASE_URL_TRANS
}
}
return XHAMSTER_BASE_URL_ETERO
}

View File

@ -0,0 +1,94 @@
import { XHAMSTER_BASE_URL, XHAMSTER_BASE_URL_VIDEOS } from "@/constants/urls";
import { FetchParams, GalleryData, VideoData, VideoSourceItem } from "@/meta/data";
import { getHeaders } from "../common/headers";
import { getDataFromRedis, storeDataIntoRedis } from "@/redis/client";
import { DEFAULT_RELATED_VIDEO_KEY_PATH, DEFAULT_XHAMSTER_GALLERY_EXPIRY, DEFAULT_XHAMSTER_VIDEO_EXPIRY } from "@/constants/redis";
import * as cheerio from "cheerio";
import axios, { AxiosError } from "axios";
import { findGetMediaUrlInTagblock } from "../common/mindgeek";
import { Platforms } from "@/meta/settings";
import { encodeUrl } from "@/utils/string";
import { DEFAULT_VIDEO_STREAM_ROUTE_PREFIX } from "@/constants/stream";
export const fetchXHamsterVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
let data: VideoData = {
srcSet: []
}
let relatedData: GalleryData[] = [];
let reqHeaders = getHeaders(XHAMSTER_BASE_URL);
const queryUrl = `${XHAMSTER_BASE_URL_VIDEOS}/${videoId.replace(/\//g, '')}`
const cachedVideoData = await getDataFromRedis(queryUrl)
const cachedRelatedData = await getDataFromRedis(queryUrl + DEFAULT_RELATED_VIDEO_KEY_PATH)
if (cachedVideoData) {
return [cachedVideoData as VideoData, cachedRelatedData as GalleryData[] ?? []]
}
await axios.get(queryUrl, reqHeaders)
.then(async response => {
const html = response.data;
const $ = cheerio.load(html);
const scriptTags = $("script");
scriptTags.map((idx, elem) => {
const hlsUrl = findGetMediaUrlInTagblock($(elem).toString().replace(/\\/g, ''), 'media=hls4') ?? null
if (hlsUrl) {
['144', '240', '360', '480', '720', '1080'].map((res: string) => {
let resUrl = findGetMediaUrlInTagblock($(elem).toString().replace(/\\/g, ''), `${res}p.h264.mp4`) ?? null
if (resUrl) {
data.srcSet?.push({
src: `${DEFAULT_VIDEO_STREAM_ROUTE_PREFIX}/${Platforms.xhamster}/${encodeUrl(resUrl)}`,
type: 'video/mp4',
size: res
})
}
});
}
})
const wrapperId = '.thumb-list .thumb-list__item'
const thumbs = $(wrapperId);
thumbs.map((key, thumb) => {
const videoUrl = $(thumb).find("a.video-thumb__image-container").attr("href")?.replace(XHAMSTER_BASE_URL_VIDEOS, '')
const imgUrl = $(thumb).find("a.video-thumb__image-container img").attr("src")
const text = $(thumb).find("a.video-thumb-info__name").attr("title")
videoUrl && imgUrl && text && relatedData.push({
videoUrl,
imgUrl,
text,
platform: Platforms.xhamster
})
})
}).catch((error: AxiosError) => {
// error handling goes here
});
if (data.srcSet && data.srcSet?.length > 0) {
await storeDataIntoRedis(queryUrl, data, DEFAULT_XHAMSTER_VIDEO_EXPIRY);
}
if (relatedData.length > 0) {
await storeDataIntoRedis(queryUrl + DEFAULT_RELATED_VIDEO_KEY_PATH, relatedData, DEFAULT_XHAMSTER_GALLERY_EXPIRY);
}
return [ data, relatedData ]
}

View File

@ -21,8 +21,30 @@ const getEncodingKey = ():string => {
return process.env.ENCODING_KEY ?? DEFAULT_ENCODING_KEY; return process.env.ENCODING_KEY ?? DEFAULT_ENCODING_KEY;
} }
// Funzione per codifica Base64 URL-safe
const base64UrlEncode = (input: string): string => {
return btoa(input)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
}
// Funzione per decodifica Base64 URL-safe
const base64UrlDecode = (input: string): string => {
let base64 = input
.replace(/-/g, '+')
.replace(/_/g, '/');
// Aggiungi padding se necessario
while (base64.length % 4) {
base64 += '=';
}
return atob(base64);
}
export function encodeUrl(url: string): string { export function encodeUrl(url: string): string {
const key = getEncodingKey() const key = getEncodingKey();
// Convert the URL and key to UTF-8 bytes // Convert the URL and key to UTF-8 bytes
const urlBytes = new TextEncoder().encode(url); const urlBytes = new TextEncoder().encode(url);
@ -31,16 +53,16 @@ export function encodeUrl(url: string): string {
// XOR the bytes of the URL with the key bytes // XOR the bytes of the URL with the key bytes
const encodedBytes = urlBytes.map((byte, index) => byte ^ keyBytes[index % keyBytes.length]); const encodedBytes = urlBytes.map((byte, index) => byte ^ keyBytes[index % keyBytes.length]);
// Convert the XORed bytes to a base64 string // Convert the XORed bytes to a base64 URL-safe string
//@ts-ignore //@ts-ignore
return btoa(String.fromCharCode(...encodedBytes)); return base64UrlEncode(String.fromCharCode(...encodedBytes));
} }
export function decodeUrl(encodedUrl: string): string { export function decodeUrl(encodedUrl: string): string {
const key = getEncodingKey() const key = getEncodingKey();
// Decode the base64 string to get the XORed bytes // Decode the base64 URL-safe string to get the XORed bytes
const encodedBytes = Uint8Array.from(atob(encodedUrl), char => char.charCodeAt(0)); const encodedBytes = Uint8Array.from(base64UrlDecode(encodedUrl), char => char.charCodeAt(0));
const keyBytes = new TextEncoder().encode(key); const keyBytes = new TextEncoder().encode(key);
// XOR the encoded bytes with the key bytes to get the original URL bytes // XOR the encoded bytes with the key bytes to get the original URL bytes