Files
lustpress/src/controller/youporn/youpornRandom.ts
Indrawan I. cd32689b47 feat(core): hard remake with bun and elysia (#19)
* static files changes

* remake modifiers

* test case

* some docs changes

* deps and rule changes

* edit proper interfaces

* remake getServer

* @elysiajs/swagger

* remake tsconfig

* ci changes use bun

* docs changes

* feat(core): hard remake with bun and elysia

* chore(release): 8.2.0-alpha

* auto release

* ci

* update global

* chore(release): 8.2.1-alpha

* ci
2026-05-14 04:57:54 +07:00

24 lines
696 B
TypeScript

import { scrapeContent } from "../../scraper/youporn/youpornGetController";
import c from "../../utils/options";
import { load } from "cheerio";
import { lust } from "../../LustPress";
export async function randomYouporn() {
try {
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);
return data;
} catch (err) {
const e = err as Error;
throw new Error(e.message);
}
}