rsshub
Version:
Make RSS Great Again!
78 lines (76 loc) • 2.41 kB
JavaScript
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 path from "node:path";
import { load } from "cheerio";
//#region lib/routes/youku/channel.ts
init_esm_shims();
const route = {
path: "/channel/:channelId/:embed?",
categories: ["multimedia"],
example: "/youku/channel/UNTg3MTM3OTcy",
parameters: {
channelId: "频道 id",
embed: "默认为开启内嵌视频, 任意值为关闭"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["i.youku.com/i/:id"],
target: "/channel/:id"
}],
name: "频道",
maintainers: ["xyqfer", "Fatpandac"],
handler
};
async function handler(ctx) {
const channelId = ctx.req.param("channelId");
const embed = !ctx.req.param("embed");
const data = (await got_default({
method: "get",
url: `https://i.youku.com/i/${channelId}/videos`,
headers: {
Host: "i.youku.com",
Referer: `https://i.youku.com/i/${channelId}`
}
})).data;
const $ = load(data);
const list = $("div.videoitem_pack");
return {
title: $(".username").text(),
link: `https://i.youku.com/i/${channelId}`,
description: $(".desc").text(),
item: list.toArray().map((item) => {
item = $(item);
const title = item.find("a.videoitem_videolink").attr("title");
const cover = item.find("a.videoitem_videolink > img").attr("src");
const $link = item.find("a.videoitem_videolink");
const link = $link.length > 0 ? `https:${$link.attr("href")}` : null;
const pubDate = parseDate(item.find("p.videoitem_subtitle").text().split("-").length === 2 ? `${(/* @__PURE__ */ new Date()).getFullYear()}-${item.find("p.videoitem_subtitle").text()}` : item.find("p.videoitem_subtitle").text());
return link ? {
title,
description: art(path.join(__dirname, "templates/channel-8f595a25.art"), {
embed,
videoId: path.parse(link).name.replaceAll(/^id_/g, ""),
cover
}),
link,
pubDate
} : null;
}).filter(Boolean)
};
}
//#endregion
export { route };