UNPKG

rsshub

Version:
61 lines (59 loc) 2.26 kB
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 path from "node:path"; import { load } from "cheerio"; //#region lib/routes/oup/index.ts init_esm_shims(); const rootUrl = "https://academic.oup.com"; const route = { path: "/journals/:name", categories: ["journal"], example: "/oup/journals/adaptation", parameters: { name: "short name for a journal, can be found in URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["academic.oup.com/", "academic.oup.com/:name/issue"] }], name: "Oxford Academic - Journal", maintainers: ["Fatpandac"], handler, url: "academic.oup.com/" }; async function handler(ctx) { const name = ctx.req.param("name"); const url = `${rootUrl}/${name}/issue`; const response = await ofetch_default.raw(url); const cookies = response.headers.getSetCookie().map((item) => item.split(";")[0]).join(";"); const $ = load(response._data); const list = $("div.al-article-items").toArray().map((item) => ({ title: $(item).find("a.at-articleLink").text(), link: new URL($(item).find("a.at-articleLink").attr("href"), rootUrl).href })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load(await ofetch_default(item.link, { headers: { Cookie: cookies } })); item.author = $$1(".al-authors-list button").text(); item.description = art(path.join(__dirname, "templates/article-9037f187.art"), { abstractContent: $$1("section.abstract > p.chapter-para").text() }); item.pubDate = parseDate($$1("div.citation-date").text()); item.category = $$1("div.kwd-group > a").toArray().map((item$1) => $$1(item$1).text()); return item; }))); return { title: `OUP - ${name}`, link: url, item: items, language: $("html").attr("lang") }; } //#endregion export { route };