mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
add: 豆瓣正在上映的高分电影
This commit is contained in:
@@ -372,6 +372,17 @@ number: 快递单号
|
||||
|
||||
参数: id,用户 id,可在用户主页 URL 中找到
|
||||
|
||||
|
||||
### 豆瓣
|
||||
|
||||
#### 正在热映的高分电影
|
||||
|
||||
举例: https://rss.now.sh/douban/playing-movie/上海/8
|
||||
|
||||
路由: `/douban/playing-movie/:city/:score`
|
||||
|
||||
参数: city,城市的中文名 score,返回大于等于这个分数的电影,
|
||||
|
||||
## 搭建
|
||||
|
||||
环境:需要 Node.js v7.6.0 或更高版本,若启用 Redis 缓存需要先启动 Redis
|
||||
|
||||
@@ -60,4 +60,6 @@ router.get('/mzitu/tag/:tag', require('./routes/mzitu/tag'));
|
||||
// // Pixiv
|
||||
router.get('/pixiv/user/:id', require('./routes/pixiv/user'));
|
||||
|
||||
// 豆瓣
|
||||
router.get('/douban/playing-movie/:city/:score', require('./routes/douban/playingMovie'));
|
||||
module.exports = router;
|
||||
|
||||
27
routes/douban/playingMovie.js
Normal file
27
routes/douban/playingMovie.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const city = ctx.params.city;
|
||||
const score = parseFloat(ctx.params.score, 10) || 7.5;
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://api.douban.com/v2/movie/in_theaters',
|
||||
params: { city }
|
||||
});
|
||||
const movieList = response.data.subjects.
|
||||
filter((item) => item.rating.average >= score);
|
||||
|
||||
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${city} 最近上映的好电影`,
|
||||
link: `https://movie.douban.com/cinema/nowplaying/${city}/`,
|
||||
description: `${city} 最近上映的评分大于等于${score}分的电影`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: movieList.map((item) => ({
|
||||
title: item.title,
|
||||
description: `中文名:${item.title}<br> 类型:${item.genres.join(' | ')} <br>评分:${item.rating.average} <br/> <img referrerpolicy="no-referrer" src="${item.images.large}">`,
|
||||
link: item.alt
|
||||
})),
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user