rsshub
Version:
Make RSS Great Again!
37 lines (36 loc) • 1.49 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { t as getAcwScV2ByArg1 } from "./utils-BiyO2GgI.mjs";
import { load } from "cheerio";
//#region lib/routes/cnu.cc/utils.ts
const picBaseUrl = "https://imgoss.cnu.cc/";
const cookieKey = "cnu:acw_sc__v2";
const cnuFetch = async (url) => {
const get = (cookie) => rofetch(url, {
responseType: "text",
headers: cookie ? { cookie: `acw_sc__v2=${cookie}` } : {}
});
const response = await get(await cache_default.get(cookieKey));
const arg1 = response.match(/var arg1='(.*?)'/)?.[1];
if (!arg1) return response;
const cookie = getAcwScV2ByArg1(arg1);
await cache_default.set(cookieKey, cookie);
return await get(cookie);
};
const parseContent = (htmlString) => {
const $ = load(htmlString);
const author = $(".author-info > a");
const time = $(".author-info > .timeago");
const content = $("#work_body");
const imgsJson = JSON.parse($("#imgs_json").text());
content.append(imgsJson.map((element) => `<img src="${picBaseUrl}${element.img}?x-oss-process=style/content" /><div class="img_description">${element.content}</div><p>${element.text}</p>`).join(""));
return {
author: author.text().trim(),
description: content.html(),
pubDate: timezone(parseDate(time.text()), 8)
};
};
//#endregion
export { parseContent as n, cnuFetch as t };