feat(route): add douban list and collections 添加豆瓣的榜单与集合 (#12100)

* add douban list

* apply changes of review

* docs: fix rendering

---------
This commit is contained in:
Hengyu
2023-03-14 21:27:58 +08:00
committed by GitHub
parent 63da6d6136
commit 22829d4af4
6 changed files with 107 additions and 3 deletions
+34 -3
View File
@@ -500,7 +500,7 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
### 用户 / 标签 - Private API
<Route author="oppilate DIYgod" example="/instagram/user/stefaniejoosten" path="/instagram/:category/:key" :paramsDesc="['类别,见下表', '用户名/标签名']" radar="1" anticrawler="1" radar="1">
<Route author="oppilate DIYgod" example="/instagram/user/stefaniejoosten" path="/instagram/:category/:key" :paramsDesc="['类别,见下表', '用户名/标签名']" radar="1" anticrawler="1" selfhost="1">
| 用户时间线 | 标签 |
| ----- | ---- |
@@ -946,7 +946,8 @@ YouTube 官方亦有提供频道 RSS,形如 <https://www.youtube.com/feeds/vid
| 热门音乐人 | 热门歌曲 | 热门音乐视频 | 时下流行 |
| ---------- | -------- | --------- | -------------- |
| TopArtists | TopSongs | TopVideos | TrendingVideos |
| ::: | | | |
:::
::: details 国家代码
@@ -985,7 +986,8 @@ YouTube 官方亦有提供频道 RSS,形如 <https://www.youtube.com/feeds/vid
| Uruguay | Zimbabwe |
| ------- | -------- |
| uy | zw |
| ::: | |
:::
</Route>
@@ -1257,6 +1259,35 @@ YouTube 官方亦有提供频道 RSS,形如 <https://www.youtube.com/feeds/vid
</Route>
### 榜单与集合
<Route author="5upernova-heng" example="/douban/list/subject_real_time_hotest" path="/douban/list/:type?" :paramsDesc="['榜单类型,见下表。默认为实时热门书影音']">
| 榜单 / 集合 | 路由(type) |
| --------- | -------------------------- |
| 实时热门书影音 | 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 |
| 虚构类小说热门榜 | book_fiction_hot_weekly |
| 非虚构类小说热门榜 | book_nonfiction_hot_weekly |
| 热门单曲榜 | music_single |
| 华语新碟榜 | music_chinese |
| ... | ... |
> 上面的榜单 / 集合并没有列举完整。
>
> 如何找到榜单对应的路由参数:
> 在豆瓣手机 APP 中,对应地榜单页面右上角,点击分享链接。链接路径 `subject_collection` 后的路径就是路由参数 `type`。
> 如:小说热门榜的分享链接为:`https://m.douban.com/subject_collection/ECDIHUN4A`,其对应本 RSS 路由的 `type` 为 `ECDIHUN4A`,对应的订阅链接路由:[`/douban/list/ECDIHUN4A`](https://rsshub.app/douban/list/ECDIHUN4A)
</Route>
## 饭否
::: warning 注意
+1
View File
@@ -11,6 +11,7 @@ module.exports = {
'/explore': ['clarkzsd'],
'/explore_column/:id': ['LogicJake'],
'/group/:groupid/:type?': ['DIYgod'],
'/list/:type?': ['5upernova-heng'],
'/jobs/:type': ['Fatpandac'],
'/movie/classification/:sort?/:score?/:tags?': ['zzwab'],
'/movie/later': ['DIYgod'],
+40
View File
@@ -0,0 +1,40 @@
const got = require('@/utils/got');
const path = require('path');
const { art } = require('@/utils/render');
module.exports = async (ctx) => {
const type = ctx.params.type || 'subject_real_time_hotest';
const url = `https://m.douban.com/rexxar/api/v2/subject_collection/${type}/items`;
const response = await got({
method: 'get',
url,
headers: {
Referer: `https://m.douban.com/subject_collection/${type}`,
},
});
const description = response.data.subject_collection.description;
const items = response.data.subject_collection_items.map((item) => {
const title = item.title;
const link = item.url;
const description = art(path.join(__dirname, '../templates/list_description.art'), {
ranking_value: item.ranking_value,
title,
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,
});
return {
title,
link,
description,
};
});
ctx.state.data = {
title: `豆瓣 - ${response.data.subject_collection.name}`,
link: 'https://m.douban.com/subject_collection/subject_real_time_hotest',
item: items,
description,
};
};
+6
View File
@@ -29,6 +29,12 @@ module.exports = {
source: '/group/:groupid',
target: '/douban/group/:groupid/elite',
},
{
title: '榜单与集合',
docs: 'https://docs.rsshub.app/social-media.html#douban',
source: ['/subject_collection/:type'],
target: '/douban/list/:type',
},
],
jobs: [
{
+1
View File
@@ -12,6 +12,7 @@ module.exports = function (router) {
router.get('/explore/column/:id', require('./other/explore_column'));
router.get('/group/:groupid/:type?', require('./other/group'));
router.get('/jobs/:type', require('./other/jobs.js'));
router.get('/list/:type?', require('./other/list'));
router.get('/movie/classification/:sort?/:score?/:tags?', require('./other/classification.js'));
router.get('/movie/later', require('./other/later'));
router.get('/movie/playing', require('./other/playing'));
@@ -0,0 +1,25 @@
{{ if ranking_value }}
<p>{{ ranking_value }}<p>
{{ /if }}
<p>{{ title }}</p>
{{ if original_title }}
<p>{{ original_title }}</p>
{{ /if }}
{{ if rate }}
<p>{{ rate }}</p>
{{ /if }}
{{ if card_subtitle }}
<p>{{ card_subtitle }}</p>
{{ /if }}
{{ if description }}
<p>{{ description }}</p>
{{ /if }}
{{ if cover }}
<img src="{{ cover }}" />
{{ /if }}