UNPKG

rsshub

Version:
74 lines (72 loc) 2.55 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 { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/iqiyi/album.ts init_esm_shims(); const route = { path: "/album/:id", categories: ["multimedia"], example: "/iqiyi/album/神武天尊-2020-1b4lufwxd7h", parameters: { id: "剧集 id, 可在该主页 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "剧集", maintainers: ["TonyRL"], handler, description: `::: tip 可抓取內容根据服务器所在地区而定 :::` }; async function handler(ctx) { const { data: response } = await got_default(`https://www.iq.com/album/${ctx.req.param("id")}`); const $ = load(response); const { album } = JSON.parse($("#__NEXT_DATA__").text()).props.initialState; const { data: { data: baseInfo } } = await got_default(`https://pcw-api.iqiyi.com/album/album/baseinfo/${album.videoAlbumInfo.albumId}`); if (Object.keys(album.cacheAlbumList).length === 0) throw new invalid_parameter_default(`${baseInfo.name} is not available in this server region.`); let pos = 1; let hasMore = false; let epgs = []; do { const { data: { data } } = await got_default(`https://pcw-api.iq.com/api/v2/episodeListSource/${album.videoAlbumInfo.albumId}`, { searchParams: { platformId: 3, modeCode: "intl", langCode: "zh_cn", endOrder: album.videoAlbumInfo.maxOrder, startOrder: pos } }); epgs = [...epgs, ...data.epg]; pos = data.pos; hasMore = data.hasMore; } while (hasMore); const items = epgs.map((item) => ({ title: item.name, description: art(path.join(__dirname, "templates/album-456d4501.art"), { item }), link: `https://www.iq.com/play/${item.playLocSuffix}`, pubDate: parseDate(item.initIssueTime) })); return { title: baseInfo.name, description: baseInfo.description, image: album.videoAlbumInfo.albumFocus1024, link: `https://www.iq.com/album/${album.videoAlbumInfo.albumLocSuffix}`, item: items, allowEmpty: true }; } //#endregion export { route };