rsshub
Version:
Make RSS Great Again!
102 lines (98 loc) • 3.75 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 path from "node:path";
import { load } from "cheerio";
//#region lib/routes/1x/index.ts
init_esm_shims();
const handler = async (ctx) => {
const { category = "latest/awarded" } = ctx.req.param();
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 30;
const rootUrl = "https://1x.com";
const currentUrl = new URL(`gallery/${category}`, rootUrl).href;
const { data: currentResponse } = await got_default(currentUrl);
const $ = load(currentResponse);
const language = $("html").prop("lang");
const apiUrl = new URL(`backend/lm2.php?style=normal&mode=${$("input#lm_mode").prop("value")}`, rootUrl).href;
const { data: response } = await got_default(apiUrl);
const items = load(response)("div.photos-feed-item").slice(0, limit).toArray().map((item) => {
item = $(item);
const title = item.find("span.photos-feed-data-title").first().text() || "Untitled";
const image$1 = item.find("img").prop("src");
const author = item.find("span.photos-feed-data-name").first().text();
const text = `${title} by ${author}`;
const description = art(path.join(__dirname, "templates/description-16be3a2a.art"), {
images: image$1 ? [{
src: image$1,
alt: title
}] : void 0,
description: text
});
const id = item.find("img[id]").prop("id").split(/-/).pop();
const guid = `1x-${id}`;
return {
title,
description,
link: new URL(`photo/${id}`, rootUrl).href,
author,
guid,
id: guid,
content: {
html: description,
text
},
image: image$1,
banner: image$1,
language,
enclosure_url: image$1,
enclosure_type: image$1 ? `image/${image$1.split(/\./).pop()}` : void 0,
enclosure_title: title
};
});
const image = new URL($("img.themedlogo").prop("src"), rootUrl).href;
return {
title: $("title").text(),
description: $("meta[name=\"description\"]").prop("content"),
link: currentUrl,
item: items,
allowEmpty: true,
image,
author: $("meta[property=\"og:site_name\"]").prop("content"),
language
};
};
const route = {
path: "/:category{.+}?",
name: "Gallery",
url: "1x.com",
maintainers: ["nczitzk"],
handler,
example: "/1x/latest/awarded",
parameters: { category: "Category, Latest Awarded by default" },
description: `::: tip
Fill in the field in the path with the part of the corresponding page URL after \`https://1x.com/gallery/\` or \`https://1x.com/photo/\`. Here are the examples:
If you subscribe to [Abstract Awarded](https://1x.com/gallery/abstract/awarded), you should fill in the path with the part \`abstract/awarded\` from the page URL \`https://1x.com/gallery/abstract/awarded\`. In this case, the route will be [\`/1x/abstract/awarded\`](https://rsshub.app/1x/abstract/awarded).
If you subscribe to [Wildlife Published](https://1x.com/gallery/wildlife/published), you should fill in the path with the part \`wildlife/published\` from the page URL \`https://1x.com/gallery/wildlife/published\`. In this case, the route will be [\`/1x/wildlife/published\`](https://rsshub.app/1x/wildlife/published).
:::`,
categories: ["design", "picture"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["/gallery/:category*", "/photos/:category*"],
target: "/1x/:category"
}]
};
//#endregion
export { handler, route };