* 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
32 lines
910 B
TypeScript
32 lines
910 B
TypeScript
import { scrapeContent as searchScrape } from "../../scraper/eporner/epornerSearchController";
|
|
import { scrapeContent as videoScrape } from "../../scraper/eporner/epornerGetController";
|
|
import c from "../../utils/options";
|
|
|
|
export async function randomEporner() {
|
|
try {
|
|
const weeklyUrl = `${c.EPORNER}/cat/all/SORT-top-weekly/`;
|
|
const list = await searchScrape(weeklyUrl);
|
|
|
|
if (!list.data.length) {
|
|
throw new Error("No weekly top videos found");
|
|
}
|
|
|
|
const random = list.data[Math.floor(Math.random() * list.data.length)];
|
|
|
|
let path: string;
|
|
|
|
if (random.id.startsWith("video-")) {
|
|
path = random.id;
|
|
} else {
|
|
path = `hd-porn/${random.id}`;
|
|
}
|
|
|
|
const url = `${c.EPORNER}/${path}`;
|
|
const data = await videoScrape(url);
|
|
|
|
return data;
|
|
} catch (err) {
|
|
const e = err as Error;
|
|
throw new Error(e.message);
|
|
}
|
|
}
|