rsshub
Version:
Make RSS Great Again!
95 lines (93 loc) • 3.22 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/fanxinzhui/index.ts
init_esm_shims();
const route = {
path: "/",
name: "最近更新",
url: "fanxinzhui.com/lastest",
maintainers: ["nczitzk"],
handler,
example: "/fanxinzhui",
categories: ["multimedia"],
radar: [{
source: ["fanxinzhui.com/lastest"],
target: "/"
}]
};
async function handler(ctx) {
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 30;
const rootUrl = "https://www.fanxinzhui.com";
const currentUrl = new URL("lastest", rootUrl).href;
const { data: response } = await got_default(currentUrl);
const $ = load(response);
let items = $("a.la").slice(0, limit).toArray().map((item) => {
item = $(item);
const season = item.find("span.season").text();
const name = item.find("span.name").text();
const link = new URL(item.prop("href"), rootUrl).href;
return {
title: `${season} ${name}`,
link,
guid: `${link}#${season}`,
pubDate: timezone(parseDate(item.find("span.time").text()), 8)
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const { data: detailResponse } = await got_default(item.link);
const content = load(detailResponse);
item.author = void 0;
item.category = [];
content("div.info ul li").each((_, el) => {
el = content(el);
const key = el.find("span").text().split(/:/)[0];
const value = el.contents().last().text().trim();
if (key === "类型") item.category = [...item.category, ...value.split(/\//)];
else if (key === "首播日期") return;
else {
item.author = `${item.author ? `${item.author}/` : ""}${value}`;
item.category = [...item.category, ...value.split(/\//)].filter((c) => c !== "等");
}
});
content("div.image").each((_, el) => {
el = content(el);
const image$1 = el.find("img").prop("src");
el.replaceWith(art(path.join(__dirname, "templates/description-463c9506.art"), { images: image$1 ? [{
src: image$1.replace(/@\d+,\d+\.\w+$/, ""),
alt: content("div.resource_title h2").text()
}] : void 0 }));
});
content("a.password").each((_, el) => {
el = content(el);
el.replaceWith(el.text());
});
item.description = content("div.middle_box").html();
item.enclosure_url = content("p.way span a").prop("href");
return item;
})));
const title = $("title").text();
const image = new URL($("img.logo").prop("src"), rootUrl).href;
return {
item: items,
title,
link: currentUrl,
description: $("meta[name=\"description\"]").prop("content"),
language: "zh",
image,
author: title.split(/_/).pop(),
allowEmpty: true
};
}
//#endregion
export { route };