UNPKG

rsshub

Version:
58 lines (55 loc) 2.24 kB
import "./dist-Bog6z_OM.mjs"; import { t as config } from "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import "./got-CO-ndVl2.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { t as config_not_found_default } from "./config-not-found-zoFMPvbz.mjs"; import { r as getUserCatalogMainContentQuery, t as parseArticle } from "./parse-article-CGuOn6fs.mjs"; //#region lib/routes/medium/list.ts const route = { path: "/list/:user/:catalogId", categories: ["blog"], example: "/medium/list/imsingee/f2d8d48096a9", parameters: { user: "Username", catalogId: "List ID" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "List", maintainers: ["ImSingee"], handler, description: `The List ID is the last part of the URL after \`-\`, for example, the username in [https://medium.com/@imsingee/list/collection-7e67004f23f9](https://medium.com/@imsingee/list/collection-7e67004f23f9) is \`imsingee\`, and the ID is \`7e67004f23f9\`. ::: warning To access private lists, only self-hosting is supported. :::` }; async function handler(ctx) { const user = ctx.req.param("user"); const catalogId = ctx.req.param("catalogId"); const cookie = config.medium.cookies[user]; const catalog = await getUserCatalogMainContentQuery(user, catalogId, cookie); ctx.set("json", catalog); if (catalog && catalog.__typename === "Forbidden") throw new config_not_found_default(`无权访问 id 为 ${catalogId} 的 List(可能是未设置 Cookie 或 Cookie 已过期)`); if (!catalog || !catalog.itemsConnection) throw new invalid_parameter_default(`id 为 ${catalogId} 的 List 不存在`); const name = catalog.name; const urls = catalog.itemsConnection.items.map((item) => item.entity.mediumUrl); const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url))); return { title: `List: ${name}`, link: `https://medium.com/@${user}/list/${catalogId}`, item: parsedArticles }; } //#endregion export { route };