UNPKG

rsshub

Version:
81 lines (77 loc) 2.49 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 "./ofetch-BIyrKU3Y.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/aip/utils.ts init_esm_shims(); const renderDesc = (title, authors, doi, img) => art(path.join(__dirname, "templates/description-b0c276be.art"), { title, authors, doi, img }); //#endregion //#region lib/routes/aip/journal.ts const route = { path: "/:pub/:jrn", categories: ["journal"], example: "/aip/aapt/ajp", parameters: { pub: "Publisher id", jrn: "Journal id" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: true }, radar: [{ source: ["pubs.aip.org/:pub/:jrn"] }], name: "Journal", maintainers: ["Derekmini", "auto-bot-ty"], handler, description: `Refer to the URL format \`pubs.aip.org/:pub/:jrn\` ::: tip More jounals can be found in [AIP Publications](https://publishing.aip.org/publications/find-the-right-journal). :::` }; async function handler(ctx) { const jrnlUrl = `https://pubs.aip.org/${ctx.req.param("pub")}/${ctx.req.param("jrn")}/issue`; const { data: response } = await got_default.get(jrnlUrl); const $ = load(response); return { title: $("meta[property=\"og:title\"]").attr("content").match(/(?:[^=]*=)?\s*([^>]+)\s*/)[1], link: jrnlUrl, item: $(".al-article-item-wrap.al-normal").toArray().map((item) => { const title = $(item).find(".item-title a:first").text(); const link = $(item).find(".item-title a:first").attr("href"); const doilink = $(item).find(".citation-label a").attr("href"); const doi = doilink && doilink.match(/10\.\d+\/\S+/)[0]; const id = $(item).find("h5[data-resource-id-access]").data("resource-id-access"); const authors = $(item).find(".al-authors-list").find("a").toArray().map((element) => $(element).text()).join("; "); const imgUrl = $(item).find(".issue-featured-image a img").attr("src"); const img = imgUrl ? imgUrl.replace(/\?.+$/, "") : ""; return { title, link, doilink, id, authors, img, doi, description: renderDesc(title, authors, doi, img) }; }), allowEmpty: true }; } //#endregion export { route };