feat(route): add 豆瓣当月期待剧集/电影推荐 (#13809)
* feat(route): add 豆瓣当月期待剧集/电影推荐 * fix * Update lib/v2/douban/other/recommended.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/douban/other/recommended.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix ---------
This commit is contained in:
parent
18fb23f018
commit
daa3f2d8b8
|
|
@ -22,6 +22,7 @@ module.exports = {
|
|||
'/music/latest/:area?': ['fengkx', 'xyqfer'],
|
||||
'/people/:userid/status/:routeParams': ['alfredcai'],
|
||||
'/people/:userid/wish/:routeParams?': ['exherb'],
|
||||
'/recommended/:type?/:routeParams?': ['honue'],
|
||||
'/replied/:uid': ['nczitzk'],
|
||||
'/replies/:uid': ['nczitzk'],
|
||||
'/topic/:id/:sort?': ['LogicJake'],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
const got = require('@/utils/got');
|
||||
const path = require('path');
|
||||
const { art } = require('@/utils/render');
|
||||
const { fallback, queryToInteger } = require('@/utils/readable-social');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const subjectType = ctx.params.type || 'tv';
|
||||
const apiKey = '0ac44ae016490db2204ce0a042db2916';
|
||||
let url = `https://frodo.douban.com/api/v2/skynet/new_playlists?apikey=${apiKey}&subject_type=${subjectType}`;
|
||||
let response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
'User-Agent': 'MicroMessenger/',
|
||||
Referer: 'https://servicewechat.com/wx2f9b06c1de1ccfca/91/page-frame.html',
|
||||
},
|
||||
});
|
||||
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const mon = date.getMonth() + 1;
|
||||
let items = response.data.data[0].items;
|
||||
|
||||
const subjectCollectionId = items.find((item) => item.title.startsWith(`${year}年${mon}月`)).id;
|
||||
|
||||
const routeParams = Object.fromEntries(new URLSearchParams(ctx.params.routeParams));
|
||||
const playable = fallback(undefined, queryToInteger(routeParams.playable), 0);
|
||||
const score = fallback(undefined, queryToInteger(routeParams.score), 0);
|
||||
|
||||
url = `https://m.douban.com/rexxar/api/v2/subject_collection/${subjectCollectionId}/items?playable=${playable}`;
|
||||
response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: `https://m.douban.com/subject_collection/${subjectCollectionId}`,
|
||||
},
|
||||
});
|
||||
const description = response.data.subject_collection.description;
|
||||
items = response.data.subject_collection_items
|
||||
.filter((item) => {
|
||||
const rate = item.rating ? item.rating.value : 0.0;
|
||||
return rate >= score; // 保留rate大于等于score的项and过滤无评分项
|
||||
})
|
||||
.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/${subjectCollectionId}`,
|
||||
item: items,
|
||||
description,
|
||||
};
|
||||
};
|
||||
|
|
@ -22,6 +22,7 @@ module.exports = function (router) {
|
|||
router.get('/music/latest/:area?', require('./other/latest_music'));
|
||||
router.get('/people/:userid/status/:routeParams?', require('./people/status.js'));
|
||||
router.get('/people/:userid/wish/:routeParams?', require('./people/wish.js'));
|
||||
router.get('/recommended/:type?/:routeParams?', require('./other/recommended'));
|
||||
router.get('/replied/:uid', require('./other/replied'));
|
||||
router.get('/replies/:uid', require('./other/replies'));
|
||||
router.get('/topic/:id/:sort?', require('./other/topic.js'));
|
||||
|
|
|
|||
|
|
@ -1438,6 +1438,25 @@ Country Code
|
|||
|
||||
</Route>
|
||||
|
||||
### 豆瓣每月推荐片单 {#dou-ban-mei-yue-tui-jian-pian-dan}
|
||||
|
||||
<Route author="honue" example="/douban/recommended/tv" path="/douban/recommended/:type?/:routeParams?" paramsDesc={['片单类型剧集/电影,tv或movie,默认为tv','额外参数;请参阅以下说明和表格']}>
|
||||
|
||||
| 额外参数 | 含义 | 接受的值 | 默认值 |
|
||||
| ---------- | ------------------ | ------- | ------ |
|
||||
| playable | 仅看有可播放片源的影片 | 0/1 | 0 |
|
||||
| score | 筛选评分 | 0-10 | 0 |
|
||||
|
||||
用例:`/douban/recommended/tv/playable=0&score=8`
|
||||
|
||||
:::tip
|
||||
|
||||
整合了/douban/list/路由,省去每月手动更新id参数,因为当月推荐剧集片单中,会有还未播出/开评分剧集、海外平台播出剧集,请自行考虑是否使用额外参数。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 饭否 {#fan-fou}
|
||||
|
||||
:::warning
|
||||
|
|
|
|||
Loading…
Reference in New Issue