rsshub
Version:
Make RSS Great Again!
48 lines (47 loc) • 1.84 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as config } from "./config-Bpyy15zS.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/xiaomi.eu/releases.ts
const route = {
path: "/releases",
categories: ["program-update"],
example: "/xiaomi.eu/releases",
name: "ROM Releases",
maintainers: ["maple3142"],
handler
};
async function handler() {
const link = "https://xiaomi.eu/community/forums/rom-releases.103/";
const $ = load(await rofetch(link));
const forums = $(".node--forum .node-title a").toArray().map((el) => `https://xiaomi.eu${$(el).attr("href")}`);
const list = (await Promise.all(forums.map((forum) => cache_default.tryGet(forum, async () => {
const $$ = load(await rofetch(forum));
return $$(".structItem--thread").toArray().map((th) => {
const $th = $$(th);
const $ver = $th.find(".structItem-title>a:nth-child(1)");
const $title = $th.find(".structItem-title>a:nth-child(2)");
return {
title: `[${$ver.text()}] ${$title.text()}`,
link: `https://xiaomi.eu${$title.attr("href")}`,
updated: $th.find(".structItem-cell--latest time").attr("datetime")
};
});
}, config.cache.routeExpire, false)))).flat().toSorted((a, b) => parseDate(b.updated).valueOf() - parseDate(a.updated).valueOf()).slice(0, 20);
return {
title: "Xiaomi.eu ROM Releases",
link,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $$ = load(await rofetch(item.link));
const floors = $$(".bbWrapper");
return {
...item,
description: floors.slice(0, 2).toArray().map((el) => $$(el).html()).join(""),
pubDate: parseDate($$("time").attr("datetime"))
};
})))
};
}
//#endregion
export { route };