rsshub
Version:
Make RSS Great Again!
100 lines (97 loc) • 2.34 kB
JavaScript
import { t as config } from "./config-C37vj7VH.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { load } from "cheerio";
//#region lib/routes/5eplay/utils.ts
const getAcwScV2ByArg1 = (arg1) => {
const pwd = "3000176000856006061501533003690027800375";
const hexXor = function(box, pwd$1) {
let res = "";
for (let i = 0; i < box.length && i < pwd$1.length; i += 2) {
let tmp = (Number.parseInt(box.slice(i, i + 2), 16) ^ Number.parseInt(pwd$1.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 (const [j, element] of code.entries()) if (element === 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$1 = "";
const matches = response.match(/var arg1='(.*?)';/);
if (matches) acw_sc__v2$1 = getAcwScV2ByArg1(matches[1]);
return acw_sc__v2$1;
}, 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$1) => content(item$1).text());
} catch {}
return item;
});
//#endregion
export { parseList as i, host as n, parseItems as r, acw_sc__v2 as t };