From 3603e016cffbf728342af8099e6af5200a59c2df Mon Sep 17 00:00:00 2001 From: sinkaroid Date: Tue, 18 Apr 2023 11:24:00 +0700 Subject: [PATCH] feat(controller): add each endpoint controller --- src/controller/pornhub/pornhubGet.ts | 55 ++++++++++++++++ src/controller/pornhub/pornhubGetRelated.ts | 55 ++++++++++++++++ src/controller/pornhub/pornhubRandom.ts | 50 ++++++++++++++ src/controller/pornhub/pornhubSearch.ts | 66 +++++++++++++++++++ src/controller/redtube/redtubeGet.ts | 56 ++++++++++++++++ src/controller/redtube/redtubeGetRelated.ts | 54 +++++++++++++++ src/controller/redtube/redtubeRandom.ts | 65 ++++++++++++++++++ src/controller/redtube/redtubeSearch.ts | 58 ++++++++++++++++ src/controller/xhamster/xhamsterGet.ts | 55 ++++++++++++++++ src/controller/xhamster/xhamsterGetRelated.ts | 55 ++++++++++++++++ src/controller/xhamster/xhamsterRandom.ts | 63 ++++++++++++++++++ src/controller/xhamster/xhamsterSearch.ts | 58 ++++++++++++++++ src/controller/xnxx/xnxxGet.ts | 55 ++++++++++++++++ src/controller/xnxx/xnxxGetRelated.ts | 55 ++++++++++++++++ src/controller/xnxx/xnxxRandom.ts | 63 ++++++++++++++++++ src/controller/xnxx/xnxxSearch.ts | 58 ++++++++++++++++ src/controller/xvideos/xvideosGet.ts | 55 ++++++++++++++++ src/controller/xvideos/xvideosGetRelated.ts | 55 ++++++++++++++++ src/controller/xvideos/xvideosRandom.ts | 63 ++++++++++++++++++ src/controller/xvideos/xvideosSearch.ts | 58 ++++++++++++++++ src/controller/youporn/youpornGet.ts | 55 ++++++++++++++++ src/controller/youporn/youpornGetRelated.ts | 55 ++++++++++++++++ src/controller/youporn/youpornRandom.ts | 62 +++++++++++++++++ src/controller/youporn/youpornSearch.ts | 58 ++++++++++++++++ 24 files changed, 1382 insertions(+) create mode 100644 src/controller/pornhub/pornhubGet.ts create mode 100644 src/controller/pornhub/pornhubGetRelated.ts create mode 100644 src/controller/pornhub/pornhubRandom.ts create mode 100644 src/controller/pornhub/pornhubSearch.ts create mode 100644 src/controller/redtube/redtubeGet.ts create mode 100644 src/controller/redtube/redtubeGetRelated.ts create mode 100644 src/controller/redtube/redtubeRandom.ts create mode 100644 src/controller/redtube/redtubeSearch.ts create mode 100644 src/controller/xhamster/xhamsterGet.ts create mode 100644 src/controller/xhamster/xhamsterGetRelated.ts create mode 100644 src/controller/xhamster/xhamsterRandom.ts create mode 100644 src/controller/xhamster/xhamsterSearch.ts create mode 100644 src/controller/xnxx/xnxxGet.ts create mode 100644 src/controller/xnxx/xnxxGetRelated.ts create mode 100644 src/controller/xnxx/xnxxRandom.ts create mode 100644 src/controller/xnxx/xnxxSearch.ts create mode 100644 src/controller/xvideos/xvideosGet.ts create mode 100644 src/controller/xvideos/xvideosGetRelated.ts create mode 100644 src/controller/xvideos/xvideosRandom.ts create mode 100644 src/controller/xvideos/xvideosSearch.ts create mode 100644 src/controller/youporn/youpornGet.ts create mode 100644 src/controller/youporn/youpornGetRelated.ts create mode 100644 src/controller/youporn/youpornRandom.ts create mode 100644 src/controller/youporn/youpornSearch.ts diff --git a/src/controller/pornhub/pornhubGet.ts b/src/controller/pornhub/pornhubGet.ts new file mode 100644 index 0000000..7b23447 --- /dev/null +++ b/src/controller/pornhub/pornhubGet.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/pornhub/pornhubGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getPornhub(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /pornhub/get?id=:id Get Pornhub + * @apiName Get pornhub + * @apiGroup pornhub + * @apiDescription Get a pornhub video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7") as resp: + * print(await resp.json()) + */ + + const url = `${c.PORNHUB}/view_video.php?viewkey=${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/pornhub/pornhubGetRelated.ts b/src/controller/pornhub/pornhubGetRelated.ts new file mode 100644 index 0000000..8672f8a --- /dev/null +++ b/src/controller/pornhub/pornhubGetRelated.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/pornhub/pornhubSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedPornhub(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /pornhub/get?id=:id Get Pornhub related videos + * @apiName Get pornhub related videos + * @apiGroup pornhub + * @apiDescription Get a related pornhub videos based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/pornhub/get?id=ph63c4e1dc48fe7") as resp: + * print(await resp.json()) + */ + + const url = `${c.PORNHUB}/view_video.php?viewkey=${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/pornhub/pornhubRandom.ts b/src/controller/pornhub/pornhubRandom.ts new file mode 100644 index 0000000..4e3f194 --- /dev/null +++ b/src/controller/pornhub/pornhubRandom.ts @@ -0,0 +1,50 @@ +import { Request, Response } from "express"; +import { scrapeContent } from "../../scraper/pornhub/pornhubGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; + +export async function randomPornhub(req: Request, res: Response) { + try { + /** + * @api {get} /pornhub/random Random pornhub video + * @apiName Random pornhub + * @apiGroup pornhub + * @apiDescription Gets random pornhub video + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/pornhub/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/pornhub/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/pornhub/random") as resp: + * print(await resp.json()) + * + */ + const url = `${c.PORNHUB}/video/random`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/pornhub/pornhubSearch.ts b/src/controller/pornhub/pornhubSearch.ts new file mode 100644 index 0000000..dba7233 --- /dev/null +++ b/src/controller/pornhub/pornhubSearch.ts @@ -0,0 +1,66 @@ +import { scrapeContent } from "../../scraper/pornhub/pornhubSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; +const sorting = ["mr", "mv", "tr", "lg"]; + +export async function searchPornhub(req: Request, res: Response) { + try { + /** + * @api {get} /pornhub/search Search pornhub videos + * @apiName Search pornhub + * @apiGroup pornhub + * @apiDescription Search pornhub videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=1] Page number + * @apiParam {String} [sort=mr] Sort by + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/pornhub/search?key=milf + * curl -i https://lust.sinkaroid.org/pornhub/search?key=milf&page=2&sort=mr + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/pornhub/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/pornhub/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 1; + const sort = req.query.sort as string; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + let url; + if (!sort) url = `${c.PORNHUB}/video/search?search=${spacer(key)}`; + else if (!sorting.includes(sort)) url = `${c.PORNHUB}/video/search?search=${spacer(key)}&page=${page}`; + + else url = `${c.PORNHUB}/video/search?search=${spacer(key)}&o=${sort}&page=${page}`; + console.log(url); + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/redtube/redtubeGet.ts b/src/controller/redtube/redtubeGet.ts new file mode 100644 index 0000000..3638c26 --- /dev/null +++ b/src/controller/redtube/redtubeGet.ts @@ -0,0 +1,56 @@ +import { scrapeContent } from "../../scraper/redtube/redtubeGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getRedtube(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + if (isNaN(Number(id))) throw Error("Parameter id must be a number"); + + /** + * @api {get} /redtube/get?id=:id Get Redtube + * @apiName Get redtube + * @apiGroup redtube + * @apiDescription Get a redtube video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/redtube/get?id=42763661 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/redtube/get?id=42763661") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/redtube/get?id=42763661") as resp: + * print(await resp.json()) + */ + + const url = `${c.REDTUBE}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/redtube/redtubeGetRelated.ts b/src/controller/redtube/redtubeGetRelated.ts new file mode 100644 index 0000000..5b7b005 --- /dev/null +++ b/src/controller/redtube/redtubeGetRelated.ts @@ -0,0 +1,54 @@ +import { scrapeContent } from "../../scraper/redtube/redtubeSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedRedtube(req: Request, res: Response) { + try { + /** + * @api {get} /redtube/get?id=:id Get redtube related videos + * @apiName Get redtube related videos + * @apiGroup redtube + * @apiDescription Get a related redtube videos based on id + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/redtube/get?id=41698751 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/redtube/get?id=41698751") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/redtube/get?id=41698751") as resp: + * print(await resp.json()) + */ + + const id = req.query.id as string; + if (!id) throw Error("Parameter key is required"); + if (isNaN(Number(id))) throw Error("Parameter id must be a number"); + + const url = `${c.REDTUBE}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/redtube/redtubeRandom.ts b/src/controller/redtube/redtubeRandom.ts new file mode 100644 index 0000000..1d6ff14 --- /dev/null +++ b/src/controller/redtube/redtubeRandom.ts @@ -0,0 +1,65 @@ +import { scrapeContent } from "../../scraper/redtube/redtubeGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; +import { load } from "cheerio"; +import LustPress from "../../LustPress"; + +const lust = new LustPress(); + +export async function randomRedtube(req: Request, res: Response) { + try { + + + /** + * @api {get} /redtube/random Get random redtube + * @apiName Get random redtube + * @apiGroup redtube + * @apiDescription Get a random redtube video + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/redtube/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/redtube/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/redtube/random") as resp: + * print(await resp.json()) + */ + const resolve = await lust.fetchBody(c.REDTUBE); + const $ = load(resolve); + const search = $("a.video_link") + .map((i, el) => { + return $(el).attr("href"); + }).get(); + const random = Math.floor(Math.random() * search.length); + + const url = c.REDTUBE + search[random]; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/redtube/redtubeSearch.ts b/src/controller/redtube/redtubeSearch.ts new file mode 100644 index 0000000..de52927 --- /dev/null +++ b/src/controller/redtube/redtubeSearch.ts @@ -0,0 +1,58 @@ +import { scrapeContent } from "../../scraper/redtube/redtubeSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function searchRedtube(req: Request, res: Response) { + try { + /** + * @api {get} /redtube/search Search redtube videos + * @apiName Search redtube + * @apiGroup redtube + * @apiDescription Search redtube videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=1] Page number + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/redtube/search?key=milf + * curl -i https://lust.sinkaroid.org/redtube/search?key=milf&page=2 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/redtube/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/redtube/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 1; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + const url = `${c.REDTUBE}/?search=${spacer(key)}&page=${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/xhamster/xhamsterGet.ts b/src/controller/xhamster/xhamsterGet.ts new file mode 100644 index 0000000..3ff50cf --- /dev/null +++ b/src/controller/xhamster/xhamsterGet.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xhamster/xhamsterGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getXhamster(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xhamster/get?id=:id Get xhamster + * @apiName Get xhamster + * @apiGroup xhamster + * @apiDescription Get a xhamster video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xhamster/get?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xhamster/get?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xhamster/get?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx") as resp: + * print(await resp.json()) + */ + + const url = `${c.XHAMSTER}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xhamster/xhamsterGetRelated.ts b/src/controller/xhamster/xhamsterGetRelated.ts new file mode 100644 index 0000000..42e09ac --- /dev/null +++ b/src/controller/xhamster/xhamsterGetRelated.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xhamster/xhamsterSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedXhamster(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xhamster/get?id=:id Get related xhamster + * @apiName Get related xhamster + * @apiGroup xhamster + * @apiDescription Get a xhamster video based on related id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xhamster/related?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xhamster/related?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xhamster/related?id=videos/horny-makima-tests-new-toy-and-cums-intensely-xhAa5wx") as resp: + * print(await resp.json()) + */ + + const url = `${c.XHAMSTER}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xhamster/xhamsterRandom.ts b/src/controller/xhamster/xhamsterRandom.ts new file mode 100644 index 0000000..981a349 --- /dev/null +++ b/src/controller/xhamster/xhamsterRandom.ts @@ -0,0 +1,63 @@ +import { scrapeContent } from "../../scraper/xhamster/xhamsterGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; +import { load } from "cheerio"; +import LustPress from "../../LustPress"; + +const lust = new LustPress(); + +export async function randomXhamster(req: Request, res: Response) { + try { + + + /** + * @api {get} /xhamster/random Get random xhamster + * @apiName Get random xhamster + * @apiGroup xhamster + * @apiDescription Get a random xhamster video + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xhamster/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xhamster/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xhamster/random") as resp: + * print(await resp.json()) + */ + const resolve = await lust.fetchBody(`${c.XHAMSTER}/newest`); + const $ = load(resolve); + const search = $("a.root-9d8b4.video-thumb-info__name.role-pop.with-dropdown") + .map((i, el) => $(el).attr("href")) + .get(); + + const search_ = search.map((el) => el.replace(c.XHAMSTER, "")); + const random = Math.floor(Math.random() * search_.length); + const url = c.XHAMSTER + search_[random]; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xhamster/xhamsterSearch.ts b/src/controller/xhamster/xhamsterSearch.ts new file mode 100644 index 0000000..ad3987a --- /dev/null +++ b/src/controller/xhamster/xhamsterSearch.ts @@ -0,0 +1,58 @@ +import { scrapeContent } from "../../scraper/xhamster/xhamsterSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function searchXhamster(req: Request, res: Response) { + try { + /** + * @api {get} /xhamster/search Search xhamster videos + * @apiName Search xhamster + * @apiGroup xhamster + * @apiDescription Search xhamster videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=1] Page number + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xhamster/search?key=milf + * curl -i https://lust.sinkaroid.org/xhamster/search?key=milf&page=2 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xhamster/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xhamster/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 1; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + const url = `${c.XHAMSTER}/search/${spacer(key)}?page=${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/xnxx/xnxxGet.ts b/src/controller/xnxx/xnxxGet.ts new file mode 100644 index 0000000..3bab609 --- /dev/null +++ b/src/controller/xnxx/xnxxGet.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xnxx/xnxxGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getXnxx(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xnxx/get?id=:id Get xnxx + * @apiName Get xnxx + * @apiGroup xnxx + * @apiDescription Get a xnxx video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xnxx/get?id=video-17vah71a/makima_y_denji + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xnxx/get?id=video-17vah71a/makima_y_denji") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xnxx/get?id=video-17vah71a/makima_y_denji") as resp: + * print(await resp.json()) + */ + + const url = `${c.XNXX}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xnxx/xnxxGetRelated.ts b/src/controller/xnxx/xnxxGetRelated.ts new file mode 100644 index 0000000..fe8c080 --- /dev/null +++ b/src/controller/xnxx/xnxxGetRelated.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xnxx/xnxxGetRelatedController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedXnxx(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xnxx/get?id=:id Get related xnxx + * @apiName Get related xnxx + * @apiGroup xnxx + * @apiDescription Get a xnxx video based on related id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xnxx/related?id=video-17vah71a/makima_y_denji + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xnxx/related?id=video-17vah71a/makima_y_denji") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xnxx/related?id=video-17vah71a/makima_y_denji") as resp: + * print(await resp.json()) + */ + + const url = `${c.XNXX}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xnxx/xnxxRandom.ts b/src/controller/xnxx/xnxxRandom.ts new file mode 100644 index 0000000..037a846 --- /dev/null +++ b/src/controller/xnxx/xnxxRandom.ts @@ -0,0 +1,63 @@ +import { scrapeContent } from "../../scraper/xnxx/xnxxGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; +import { load } from "cheerio"; +import LustPress from "../../LustPress"; + +const lust = new LustPress(); + +export async function randomXnxx(req: Request, res: Response) { + try { + + + /** + * @api {get} /xnxx/random Get random xnxx + * @apiName Get random xnxx + * @apiGroup xnxx + * @apiDescription Get a random xnxx video + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xnxx/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xnxx/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xnxx/random") as resp: + * print(await resp.json()) + */ + const resolve = await lust.fetchBody("https://www.xnxx.com/search/random/random"); + const $ = load(resolve); + const search = $("div.mozaique > div") + .map((i, el) => { + return $(el).find("a").attr("href"); + }).get(); + const random = Math.floor(Math.random() * search.length); + + const url = c.XNXX + search[random]; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xnxx/xnxxSearch.ts b/src/controller/xnxx/xnxxSearch.ts new file mode 100644 index 0000000..3b5319b --- /dev/null +++ b/src/controller/xnxx/xnxxSearch.ts @@ -0,0 +1,58 @@ +import { scrapeContent } from "../../scraper/xnxx/xnxxSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function searchXnxx(req: Request, res: Response) { + try { + /** + * @api {get} /xnxx/search Search xnxx videos + * @apiName Search xnxx + * @apiGroup xnxx + * @apiDescription Search xnxx videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=0] Page number + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xnxx/search?key=milf + * curl -i https://lust.sinkaroid.org/xnxx/search?key=milf&page=2 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xnxx/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xnxx/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 0; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + const url = `${c.XNXX}/search/${spacer(key)}/${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/xvideos/xvideosGet.ts b/src/controller/xvideos/xvideosGet.ts new file mode 100644 index 0000000..02e5795 --- /dev/null +++ b/src/controller/xvideos/xvideosGet.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xvideos/xvideosGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getXvideos(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xvideos/get?id=:id Get xvideos + * @apiName Get xvideos + * @apiGroup xvideos + * @apiDescription Get a xvideos video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xvideos/get?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_ + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xvideos/get?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xvideos/get?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_") as resp: + * print(await resp.json()) + */ + + const url = `${c.XVIDEOS}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xvideos/xvideosGetRelated.ts b/src/controller/xvideos/xvideosGetRelated.ts new file mode 100644 index 0000000..deb758a --- /dev/null +++ b/src/controller/xvideos/xvideosGetRelated.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/xvideos/xvideosGetRelatedController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedXvideos(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /xvideos/get?id=:id Get related xvideos + * @apiName Get related xvideos + * @apiGroup xvideos + * @apiDescription Get a xvideos video based on related id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xvideos/related?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_ + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xvideos/related?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xvideos/related?id=video73564387/cute_hentai_maid_with_pink_hair_fucking_uncensored_") as resp: + * print(await resp.json()) + */ + + const url = `${c.XVIDEOS}/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xvideos/xvideosRandom.ts b/src/controller/xvideos/xvideosRandom.ts new file mode 100644 index 0000000..99d51ce --- /dev/null +++ b/src/controller/xvideos/xvideosRandom.ts @@ -0,0 +1,63 @@ +import { scrapeContent } from "../../scraper/xvideos/xvideosGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; +import { load } from "cheerio"; +import LustPress from "../../LustPress"; + +const lust = new LustPress(); + +export async function randomXvideos(req: Request, res: Response) { + try { + /** + * @api {get} /xvideos/random Get random xvideos + * @apiName Get random xvideos + * @apiGroup xvideos + * @apiDescription Get a random xvideos video + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xvideos/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xvideos/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xvideos/random") as resp: + * print(await resp.json()) + */ + const resolve = await lust.fetchBody(c.XVIDEOS); + const $ = load(resolve); + const search = $("div.thumb-under") + .find("a") + .map((i, el) => $(el).attr("href")) + .get(); + const filtered = search.filter((el) => el.includes("/video")); + const filtered_ = filtered.filter((el) => !el.includes("THUMBNUM")); + const random = Math.floor(Math.random() * filtered_.length); + + const url = c.XVIDEOS + filtered[random]; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/xvideos/xvideosSearch.ts b/src/controller/xvideos/xvideosSearch.ts new file mode 100644 index 0000000..3a0d0a1 --- /dev/null +++ b/src/controller/xvideos/xvideosSearch.ts @@ -0,0 +1,58 @@ +import { scrapeContent } from "../../scraper/xvideos/xvideosSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function searchXvideos(req: Request, res: Response) { + try { + /** + * @api {get} /xvideos/search Search xvideos videos + * @apiName Search xvideos + * @apiGroup xvideos + * @apiDescription Search xvideos videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=0] Page number + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/xvideos/search?key=milf + * curl -i https://lust.sinkaroid.org/xvideos/search?key=milf&page=2 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/xvideos/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/xvideos/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 0; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + const url = `${c.XVIDEOS}/?k=${spacer(key)}&p=${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file diff --git a/src/controller/youporn/youpornGet.ts b/src/controller/youporn/youpornGet.ts new file mode 100644 index 0000000..14c80aa --- /dev/null +++ b/src/controller/youporn/youpornGet.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/youporn/youpornGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function getYouporn(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /youporn/get?id=:id Get youporn + * @apiName Get youporn + * @apiGroup youporn + * @apiDescription Get a youporn video based on id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/youporn/get?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/youporn/get?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/youporn/get?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps") as resp: + * print(await resp.json()) + */ + + const url = `${c.YOUPORN}/watch/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/youporn/youpornGetRelated.ts b/src/controller/youporn/youpornGetRelated.ts new file mode 100644 index 0000000..2bfaef1 --- /dev/null +++ b/src/controller/youporn/youpornGetRelated.ts @@ -0,0 +1,55 @@ +import { scrapeContent } from "../../scraper/youporn/youpornSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function relatedYouporn(req: Request, res: Response) { + try { + const id = req.query.id as string; + if (!id) throw Error("Parameter id is required"); + + /** + * @api {get} /youporn/get?id=:id Get related youporn + * @apiName Get related youporn + * @apiGroup youporn + * @apiDescription Get a youporn video based on related id + * + * @apiParam {String} id Video ID + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/youporn/related?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/youporn/related?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/youporn/related?id=16621192/chainsaw-man-fuck-makima-3d-porn-60-fps") as resp: + * print(await resp.json()) + */ + + const url = `${c.YOUPORN}/watch/${id}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/youporn/youpornRandom.ts b/src/controller/youporn/youpornRandom.ts new file mode 100644 index 0000000..9f1d49e --- /dev/null +++ b/src/controller/youporn/youpornRandom.ts @@ -0,0 +1,62 @@ +import { scrapeContent } from "../../scraper/youporn/youpornGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError } from "../../utils/modifier"; +import { Request, Response } from "express"; +import { load } from "cheerio"; +import LustPress from "../../LustPress"; + +const lust = new LustPress(); + +export async function randomYouporn(req: Request, res: Response) { + try { + + + /** + * @api {get} /youporn/random Get random youporn + * @apiName Get random youporn + * @apiGroup youporn + * @apiDescription Get a random youporn video + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/youporn/random + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/youporn/random") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/youporn/random") as resp: + * print(await resp.json()) + */ + const resolve = await lust.fetchBody(`${c.YOUPORN}`); + const $ = load(resolve); + const search = $("a[href^='/watch/']") + .map((i, el) => { + return $(el).attr("href"); + }).get(); + const random = Math.floor(Math.random() * search.length); + const url = c.YOUPORN + search[random]; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} diff --git a/src/controller/youporn/youpornSearch.ts b/src/controller/youporn/youpornSearch.ts new file mode 100644 index 0000000..6a31082 --- /dev/null +++ b/src/controller/youporn/youpornSearch.ts @@ -0,0 +1,58 @@ +import { scrapeContent } from "../../scraper/youporn/youpornSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; +import { maybeError, spacer } from "../../utils/modifier"; +import { Request, Response } from "express"; + +export async function searchYouporn(req: Request, res: Response) { + try { + /** + * @api {get} /youporn/search Search youporn videos + * @apiName Search youporn + * @apiGroup youporn + * @apiDescription Search youporn videos + * @apiParam {String} key Keyword to search + * @apiParam {Number} [page=1] Page number + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * HTTP/1.1 400 Bad Request + * + * @apiExample {curl} curl + * curl -i https://lust.sinkaroid.org/youporn/search?key=milf + * curl -i https://lust.sinkaroid.org/youporn/search?key=milf&page=2 + * + * @apiExample {js} JS/TS + * import axios from "axios" + * + * axios.get("https://lust.sinkaroid.org/youporn/search?key=milf") + * .then(res => console.log(res.data)) + * .catch(err => console.error(err)) + * + * @apiExample {python} Python + * import aiohttp + * async with aiohttp.ClientSession() as session: + * async with session.get("https://lust.sinkaroid.org/youporn/search?key=milf") as resp: + * print(await resp.json()) + */ + + const key = req.query.key as string; + const page = req.query.page || 1; + if (!key) throw Error("Parameter key is required"); + if (isNaN(Number(page))) throw Error("Parameter page must be a number"); + + const url = `${c.YOUPORN}/search/?query=${spacer(key)}&page=${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err) { + const e = err as Error; + res.status(400).json(maybeError(false, e.message)); + } +} \ No newline at end of file