-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(controller): add each endpoint controller
- Loading branch information
Showing
24 changed files
with
1,382 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
Oops, something went wrong.