rsshub
Version:
Make RSS Great Again!
90 lines (88 loc) • 3.27 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 { 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 art } from "./render-BQo6B4tL.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import dayjs from "dayjs";
import { load } from "cheerio";
//#region lib/routes/stdaily/digitalpaper.ts
init_esm_shims();
const SITE_ID = "811c18b08cf04e79be3b67d6902ee1a7";
const CODE = "KJRB";
const API_HOST = "https://epaper.stdaily.com/stdailynewspaperapi";
const route = {
path: "/digitalpaper",
categories: ["traditional-media"],
example: "/stdaily/digitalpaper",
name: "科技日报",
maintainers: ["lyqluis", "KarasuShin"],
handler,
features: { supportRadar: true },
radar: [{
source: ["epaper.stdaily.com/statics/technology-site/index.html"],
target: "/digitalpaper"
}]
};
async function handler() {
const lastDate = (await ofetch_default(`${API_HOST}/uv/article/period/date`, {
method: "POST",
body: {
code: CODE,
date: dayjs(/* @__PURE__ */ new Date(), "YYYY-MM-01")
},
headers: { "X-Requested-With": "XMLHttpRequest" }
})).obj.dateList.toSorted().at(-1);
const sectionListResponse = await ofetch_default(`${API_HOST}/uv/article/period/periodTime`, {
method: "POST",
body: {
code: CODE,
periodTime: lastDate,
siteId: SITE_ID
},
headers: { "X-Requested-With": "XMLHttpRequest" }
});
return {
title: "中国科技网 - 科技日报",
link: "https://epaper.stdaily.com",
item: (await Promise.all(sectionListResponse.obj.editionList.map((section) => cache_default.tryGet(`stdaily:epaper:${section.id}`, async () => {
const { list } = await ofetch_default(`${API_HOST}/uv/article/article/editionId`, {
method: "POST",
body: {
id: section.id,
siteId: SITE_ID
},
headers: { "X-Requested-With": "XMLHttpRequest" }
});
return await Promise.all(list.map(async (article) => await cache_default.tryGet(`stddaily:epaper:article:${article.id}`, async () => {
const { obj: { articleVo } } = await ofetch_default(`${API_HOST}/uv/article/article/articleId`, {
method: "POST",
body: {
code: CODE,
id: article.id,
siteId: SITE_ID
},
headers: { "X-Requested-With": "XMLHttpRequest" }
});
return {
title: `${articleVo.editionName.match(/:(.*)/)?.[1]} - ${load(articleVo.title).text()}`,
description: art(path.join(__dirname, "templates/description-9a4423f3.art"), {
subtitle: articleVo.subtitle,
pics: articleVo.picList ?? [],
content: articleVo.content
}),
pubDate: timezone(parseDate(articleVo.periodTime), 8),
author: articleVo.author,
link: `https://epaper.stdaily.com/statics/technology-site/index.html#/home?isDetail=1¤tNewsId=${article.id}¤tVersionName=${articleVo.editionName}¤tVersion=${Number(section.editionCode)}&timeValue=${articleVo.periodTime}`
};
})));
})))).flat(),
image: "https://www.stdaily.com/favicon.ico"
};
}
//#endregion
export { route };