rsshub
Version:
Make RSS Great Again!
65 lines (63 loc) • 2.18 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 "./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 { t as isValidHost } from "./valid-host-C-u5eW3j.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/gumroad/index.ts
init_esm_shims();
const route = {
path: "/:username/:products",
categories: ["shopping"],
example: "/gumroad/afkmaster/Eve10",
parameters: {
username: "username, can be found in URL",
products: "products name, can be found in URL"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "Products",
maintainers: ["Fatpandac"],
handler,
description: `\`https://afkmaster.gumroad.com/l/Eve10\` -> \`/gumroad/afkmaster/Eve10\``
};
async function handler(ctx) {
const username = ctx.req.param("username");
const products = ctx.req.param("products");
if (!isValidHost(username)) throw new invalid_parameter_default("Invalid username");
const url = `https://${username}.gumroad.com/l/${products}`;
const response = await got_default(url);
const $ = load(response.data);
const title = $("section.product-content.product-content__row > header > h1").text();
const userFullName = $("section.product-content.product-content__row > section.details > a").text();
const item = [{
title,
link: url,
description: art(path.join(__dirname, "templates/products-8761a3c9.art"), {
img: response.data.match(/data-preview-url="(.*?)"/)[1],
productsName: title,
price: $("div.price").text(),
desc: $("section.product-content.product-content__row > section:nth-child(3) > div").html(),
stack: $("div.product-info").find("ul.stack").html()
})
}];
return {
link: url,
title: `Gumroad - ${userFullName}/${title}`,
item
};
}
//#endregion
export { route };