douban movie intheaters: optional city

This commit is contained in:
DIYgod
2018-04-21 19:47:48 +08:00
parent fef37dd6f8
commit a0dbb33580
5 changed files with 48 additions and 33 deletions
+3
View File
@@ -48,6 +48,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 详情
- pixiv
- 用户动态
- 豆瓣
- 正在上映的电影
- 正在上映的高分电影
## 参与我们
+16 -5
View File
@@ -372,16 +372,27 @@ number: 快递单号
参数: id,用户 id,可在用户主页 URL 中找到
### 豆瓣
#### 正在热映的高分电影
#### 正在上映的电影
举例: https://rss.now.sh/douban/playing-movie/上海/8
举例: https://rss.now.sh/douban/movie/intheaters
路由: `/douban/playing-movie/:city/:score`
路由: `/douban/movie/intheaters`
参数: city,城市的中文名 score,返回大于等于这个分数的电影,
参数: 无
#### 正在上映的高分电影
举例: https://rss.now.sh/douban/movie/intheaters/7.5
路由: `/douban/movie/intheaters/:score/:city`
参数
score: 返回大于等于这个分数的电影
city: 城市的中文名,可选,默认北京
## 搭建
+4 -1
View File
@@ -61,5 +61,8 @@ router.get('/mzitu/tag/:tag', require('./routes/mzitu/tag'));
router.get('/pixiv/user/:id', require('./routes/pixiv/user'));
// 豆瓣
router.get('/douban/playing-movie/:city/:score', require('./routes/douban/playingMovie'));
router.get('/douban/movie/intheaters', require('./routes/douban/intheaters'));
router.get('/douban/movie/intheaters/:score', require('./routes/douban/intheaters'));
router.get('/douban/movie/intheaters/:score/:city', require('./routes/douban/intheaters'));
module.exports = router;
+25
View File
@@ -0,0 +1,25 @@
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);
const response = await axios({
method: 'get',
url: 'https://api.douban.com/v2/movie/in_theaters',
params: { city }
});
const movieList = score ? response.data.subjects.filter((item) => item.rating.average >= score) : response.data.subjects;
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
title: `${city ? city : ''}正在上映的${score ? `超过 ${score} 分的` : ''}电影`,
link: 'https://movie.douban.com/cinema/nowplaying/',
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
})),
});
};
-27
View File
@@ -1,27 +0,0 @@
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
})),
});
};