rsshub
Version:
Make RSS Great Again!
56 lines (54 loc) • 2.09 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
//#region lib/routes/otobanana/utils.ts
init_esm_shims();
const domain = "otobanana.com";
const apiBase = `https://api.${domain}`;
const baseUrl = `https://${domain}`;
const getUserInfo = (id, tryGet) => tryGet(`otobanana:user:${id}`, async () => {
const { data } = await got_default(`${apiBase}/users/${id}/`);
return data;
});
const renderCast = (cast) => ({
title: cast.title,
description: art(path.join(__dirname, "templates/description-161b5c63.art"), { cast }),
pubDate: parseDate(cast.created_at),
link: `https://otobanana.com/cast/${cast.id}`,
author: `${cast.user.name} (@${cast.user.username})`,
itunes_item_image: cast.thumbnail_url,
itunes_duration: cast.duration_time,
enclosure_url: cast.audio_url,
enclosure_type: "audio/x-m4a",
upvotes: cast.like_count,
comments: cast.comment_count
});
const renderLive = (live) => ({
title: live.title,
description: live.is_open ? "配信中のライブ" : "終了しました",
pubDate: parseDate(live.created_at),
link: live.room_url,
guid: `${live.room_url}#${live.id}`,
author: `${live.user.name} (@${live.user.username})`,
upvotes: live.like_count,
comments: live.comment_count
});
const renderPost = ({ id, type_label: type, cast, message }) => {
switch (type) {
case "cast": return renderCast(cast);
case "message": return {
title: message.text.split("\n")[0],
description: message.text.replaceAll("\n", "<br>"),
pubDate: parseDate(message.created_at),
link: `https://otobanana.com/${type}/${id}`,
author: `${message.user.name} (@${message.user.username})`,
upvotes: message.like_count,
comments: message.comment_count
};
default: throw new Error(`Unknown post type: ${type}`);
}
};
//#endregion
export { renderLive as a, renderCast as i, baseUrl as n, renderPost as o, getUserInfo as r, apiBase as t };