Skip to content

Commit

Permalink
feat(douban): add description (#17214)
Browse files Browse the repository at this point in the history
* feat(douban): add description

* fix: restore old description

---------
  • Loading branch information
haowenwu authored Oct 21, 2024
1 parent 1a94319 commit 58e61cc
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions lib/routes/douban/people/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@ import querystring from 'querystring';
import got from '@/utils/got';
import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-social';
import { config } from '@/config';
export const route: Route = {
path: '/people/:userid/status/:routeParams?',
categories: ['social-media'],
example: '/douban/people/75118396/status',
parameters: { userid: '整数型用户 id', routeParams: '额外参数;见下' },
name: '用户广播',
maintainers: ['alfredcai'],
handler,
description: `
::: tip
- **目前只支持整数型 id**
- 字母型的 id,可以通过头像图片链接来找到其整数型 id,图片命名规则\`ul[userid]-*.jpg\`或\`u[userid]-*.jpg\`,即取文件名中间的数字
- 例如:用户 id: \`MovieL\`他的头像图片链接:\`https://img1.doubanio.com/icon/ul1128221-98.jpg\`他的整数型 id: \`1128221\`
:::
对于豆瓣用户广播内容,在 \`routeParams\` 参数中以 query string 格式设置如下选项可以控制输出的样式
| 键 | 含义 | 接受的值 | 默认值 |
| -------------------------- | -------------------------------------------------------------- | -------------- | ------ |
| readable | 是否开启细节排版可读性优化 | 0/1/true/false | false |
| authorNameBold | 是否加粗作者名字 | 0/1/true/false | false |
| showAuthorInTitle | 是否在标题处显示作者 | 0/1/true/false | true |
| showAuthorInDesc | 是否在正文处显示作者 | 0/1/true/false | false |
| showAuthorAvatarInDesc | 是否在正文处显示作者头像(若阅读器会提取正文图片,不建议开启) | 0/1/true/false | false |
| showEmojiForRetweet | 显示 “🔁” 取代 “Fw”(转发) | 0/1/true/false | false |
| showRetweetTextInTitle | 在标题出显示转发评论(置为 false 则在标题只显示被转发的广播) | 0/1/true/false | false |
| addLinkForPics | 为图片添加可点击的链接 | 0/1/true/false | false |
| showTimestampInDescription | 在正文处显示广播的时间戳 | 0/1/true/false | false |
| showComments | 在正文处显示评论 | 0/1/true/false | false |
| widthOfPics | 广播配图宽(生效取决于阅读器) | 不指定 / 数字 | 不指定 |
| heightOfPics | 广播配图高(生效取决于阅读器) | 不指定 / 数字 | 不指定 |
| sizeOfAuthorAvatar | 作者头像大小 | 数字 | 48 |
指定更多与默认值不同的参数选项可以改善 RSS 的可读性,如
[https://rsshub.app/douban/people/113894409/status/readable=1&authorNameBold=1&showAuthorInTitle=1&showAuthorInDesc=1&showAuthorAvatarInDesc=1&showEmojiForRetweet=1&showRetweetTextInTitle=1&addLinkForPics=1&showTimestampInDescription=1&showComments=1&widthOfPics=100](https://rsshub.app/douban/people/113894409/status/readable=1&authorNameBold=1&showAuthorInTitle=1&showAuthorInDesc=1&showAuthorAvatarInDesc=1&showEmojiForRetweet=1&showRetweetTextInTitle=1&addLinkForPics=1&showTimestampInDescription=1&showComments=1&widthOfPics=100)
的效果为
<img loading="lazy" src="/img/readable-douban.png" alt="豆瓣读书的可读豆瓣广播 RSS" />`,
};

const headers = { Referer: `https://m.douban.com/` };

Expand Down Expand Up @@ -444,13 +485,6 @@ async function getFullTextItems(items) {
);
}

export const route: Route = {
path: '/people/:userid/status/:routeParams?',
name: 'Unknown',
maintainers: [],
handler,
};

async function handler(ctx) {
const userid = ctx.req.param('userid');
const url = `https://m.douban.com/rexxar/api/v2/status/user_timeline/${userid}`;
Expand Down

0 comments on commit 58e61cc

Please sign in to comment.