rsshub
Version:
Make RSS Great Again!
122 lines (117 loc) • 5.08 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 { i as queryToInteger, r as queryToFloat, t as fallback } from "./readable-social-DoIL4WB3.mjs";
import path from "node:path";
//#region lib/routes/douban/other/list.ts
init_esm_shims();
const route = {
path: "/list/:type?/:routeParams?",
categories: ["social-media"],
example: "/douban/list/subject_real_time_hotest",
parameters: {
type: "榜单类型,见下表。默认为实时热门书影音",
routeParams: "额外参数;请参阅以下说明和表格"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["www.douban.com/subject_collection/:type"],
target: "/list/:type"
}],
name: "豆瓣榜单与集合",
maintainers: ["5upernova-heng", "honue"],
handler,
description: `| 榜单 / 集合 | 路由 |
| ------------------ | ----------------------------- |
| 实时热门书影音 | subject\_real\_time\_hotest |
| 影院热映 | movie\_showing |
| 实时热门电影 | movie\_real\_time\_hotest |
| 实时热门电视 | tv\_real\_time\_hotest |
| 一周口碑电影榜 | movie\_weekly\_best |
| 华语口碑剧集榜 | tv\_chinese\_best\_weekly |
| 全球口碑剧集榜 | tv\_global\_best\_weekly |
| 国内口碑综艺榜 | show\_chinese\_best\_weekly |
| 国外口碑综艺榜 | show\_global\_best\_weekly |
| 热播新剧国产剧 | tv\_domestic |
| 热播新剧欧美剧 | tv\_american |
| 热播新剧日剧 | tv\_japanese |
| 热播新剧韩剧 | tv\_korean |
| 热播新剧动画 | tv\_animation |
| 虚构类小说热门榜 | book\_fiction\_hot\_weekly |
| 非虚构类小说热门榜 | book\_nonfiction\_hot\_weekly |
| 热门单曲榜 | music\_single |
| 华语新碟榜 | music\_chinese |
| ... | ... |
| 额外参数 | 含义 | 接受的值 | 默认值 |
| -------- | ---------------------- | -------- | ------ |
| playable | 仅看有可播放片源的影片 | 0/1 | 0 |
| score | 筛选评分 | 0.0-10.0 | 0 |
用例:\`/douban/list/tv_korean/playable=1&score=8\`
> 上面的榜单 / 集合并没有列举完整。
>
> 如何找到榜单对应的路由参数:
> 在豆瓣手机 APP 中,对应地榜单页面右上角,点击分享链接。链接路径 \`subject_collection\` 后的路径就是路由参数 \`type\`。
> 如:小说热门榜的分享链接为:\`https://m.douban.com/subject_collection/ECDIHUN4A\`,其对应本 RSS 路由的 \`type\` 为 \`ECDIHUN4A\`,对应的订阅链接路由:[\`/douban/list/ECDIHUN4A\`](https://rsshub.app/douban/list/ECDIHUN4A)`
};
async function handler(ctx) {
const type = ctx.req.param("type") || "subject_real_time_hotest";
const routeParams = Object.fromEntries(new URLSearchParams(ctx.req.param("routeParams")));
const playable = fallback(void 0, queryToInteger(routeParams.playable), 0);
const score = fallback(void 0, queryToFloat(routeParams.score), 0);
let start = 0;
const count = 50;
let items = [];
let title = "";
let description = "";
let total = null;
while (total === null || start < total) {
const response = await got_default({
method: "get",
url: `https://m.douban.com/rexxar/api/v2/subject_collection/${type}/items?playable=${playable}&start=${start}&count=${count}`,
headers: { Referer: `https://m.douban.com/subject_collection/${type}` }
});
title = response.data.subject_collection.name;
description = response.data.subject_collection.description;
total = response.data.total;
const newItems = response.data.subject_collection_items.filter((item) => {
return (item.rating ? item.rating.value : 0) >= score;
}).map((item) => {
const title$1 = item.title;
return {
title: title$1,
link: item.url,
description: art(path.join(__dirname, "templates/list_description-833a570f.art"), {
ranking_value: item.ranking_value,
title: title$1,
original_title: item.original_title,
rate: item.rating ? item.rating.value : null,
card_subtitle: item.card_subtitle,
description: item.cards ? item.cards[0].content : item.abstract,
cover: item.cover_url || item.cover?.url
})
};
});
items = [...items, ...newItems];
start += count;
}
return {
title: `豆瓣 - ${title}`,
link: `https://m.douban.com/subject_collection/${type}`,
item: items,
description
};
}
//#endregion
export { route };