rsshub
Version:
Make RSS Great Again!
92 lines (90 loc) • 2.99 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 { t as cache_default } from "./cache-Bo__VnGm.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/vimeo/channel.ts
init_esm_shims();
const route = {
path: "/channel/:channel",
categories: ["social-media"],
example: "/vimeo/channel/bestoftheyear",
parameters: { channel: "channel name can get from url like `bestoftheyear` in [https://vimeo.com/channels/bestoftheyear/videos](https://vimeo.com/channels/bestoftheyear/videos) ." },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: [
"vimeo.com/channels/:channel",
"vimeo.com/channels/:channel/videos",
"vimeo.com/channels/:channel/videos/:sort/:format"
] }],
name: "Channel",
maintainers: ["MisteryMonster"],
handler
};
async function handler(ctx) {
const channel = ctx.req.param("channel");
const url = `https://vimeo.com/channels/${channel}/videos`;
const page1 = await got_default({
method: "get",
url: `${url}/page:1/sort:date/format:detail`,
headers: { "X-Requested-With": "XMLHttpRequest" }
});
const page2 = channel === `bestoftheyear` ? await got_default({
method: "get",
url: `${url}/page:2/sort:date/format:detail`,
headers: { "X-Requested-With": "XMLHttpRequest" }
}) : "";
const $ = load([...page1.data, ...page2.data]);
const list = $("ol li.clearfix");
const description = await Promise.all(list.toArray().map((item) => {
item = $(item);
const link = item.find(".more").attr("href");
return cache_default.tryGet(link, async () => {
const articledata = (await got_default({
method: "get",
url: `https://vimeo.com${link}/description?breeze=1`,
headers: {
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "
}
})).data;
const $2 = load(articledata);
$2("span").remove();
return $2.html();
});
}));
return {
title: `${channel} | Vimeo channel`,
link: url,
item: list.toArray().map((item, index) => {
item = $(item);
const title = item.find(".title a").text();
const author = item.find(".meta a").text();
return {
title,
description: art(path.join(__dirname, "templates/description-f7979603.art"), {
videoUrl: item.find(".more").attr("href"),
vdescription: description[index] || ""
}),
pubDate: parseDate(item.find("time").attr("datetime")),
link: `https://vimeo.com${item.find(".more").attr("href")}`,
author
};
})
};
}
//#endregion
export { route };