rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 1.98 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/my-formosa/index.ts
const route = {
path: "/",
categories: ["new-media"],
example: "/my-formosa",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["my-formosa.com/"] }],
name: "首页",
maintainers: ["dzx-dzx"],
handler,
url: "my-formosa.com"
};
function fetch(url) {
return ofetch_default(url, { responseType: "arrayBuffer" }).then((raw) => {
return new TextDecoder("big5").decode(raw);
});
}
async function handler() {
const rootUrl = "http://www.my-formosa.com/";
const $ = load(await fetch(rootUrl));
const items = await Promise.all($("#featured-news h3 a").toArray().map((item) => {
item = $(item);
const title = item.text();
const link = new URL(item.attr("href"), rootUrl).href;
return cache_default.tryGet(link, async () => {
const $$1 = load(await fetch(link));
const isTV = /^\/TV/.test(new URL(link).pathname);
return {
title,
link,
author: $$1(".page-header~#featured-news h4").text(),
category: $$1("meta[name='keywords']").attr("content").split(",").filter(Boolean),
pubDate: timezone(parseDate((isTV ? $$1(".icon-calendar")[0].next.data : $$1(".date").text()).trim()), 8),
description: (isTV ? $$1(".post-item").html() : $$1(".body").html()).replaceAll(/\/News.*?\.jpg/g, (match) => `http://my-formosa.com${match}`)
};
});
}));
return {
title: $("title").text(),
link: rootUrl,
item: items
};
}
//#endregion
export { route };