rsshub
Version:
Make RSS Great Again!
100 lines (97 loc) • 2.32 kB
JavaScript
import { t as config } from "./config-MQ-7ebJ_.mjs";
import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import { load } from "cheerio";
//#region lib/routes/5eplay/utils.ts
const getAcwScV2ByArg1 = (arg1) => {
const pwd = "3000176000856006061501533003690027800375";
const hexXor = function(box, pwd) {
let res = "";
for (let i = 0; i < box.length && i < pwd.length; i += 2) {
let tmp = (Number.parseInt(box.slice(i, i + 2), 16) ^ Number.parseInt(pwd.slice(i, i + 2), 16)).toString(16);
if (tmp.length === 1) tmp = "0" + tmp;
res += tmp;
}
return res;
};
const unsbox = function(str) {
const code = [
15,
35,
29,
24,
33,
16,
1,
38,
10,
9,
19,
31,
40,
27,
22,
23,
25,
13,
6,
11,
39,
18,
20,
8,
14,
21,
32,
26,
2,
30,
7,
4,
17,
5,
3,
28,
34,
37,
12,
36
];
const res = [];
for (let i = 0; i < str.length; i++) {
const cur = str[i];
for (let j = 0; j < code.length; j++) if (code[j] === i + 1) res[j] = cur;
}
return res.join("");
};
return hexXor(unsbox(arg1), pwd);
};
//#endregion
//#region lib/routes/segmentfault/utils.ts
const host = "https://segmentfault.com";
const acw_sc__v2 = (link, tryGet) => tryGet("segmentfault:acw_sc__v2", async () => {
const response = await ofetch_default(link);
let acw_sc__v2 = "";
const matches = response.match(/var arg1='(.*?)';/);
if (matches) acw_sc__v2 = getAcwScV2ByArg1(matches[1]);
return acw_sc__v2;
}, config.cache.routeExpire, false);
const parseList = (data) => data.map((item) => ({
title: item.title,
link: new URL(item.url, host).href,
author: item.user.name,
pubDate: parseDate(item.created || item.modified, "X"),
description: item.excerpt
}));
const parseItems = (cookie, item, tryGet) => tryGet(item.link, async () => {
let response;
try {
response = await ofetch_default(item.link, { headers: { cookie: `acw_sc__v2=${cookie};` } });
const content = load(response);
item.description = content("article").html();
item.category = content(".badge-tag").toArray().map((item) => content(item).text());
} catch {}
return item;
});
//#endregion
export { parseList as i, host as n, parseItems as r, acw_sc__v2 as t };