feat: add 豆瓣一周口碑榜 (#6049)

This commit is contained in:
Ethan Shen 2020-10-30 17:11:33 +08:00 committed by GitHub
parent e44064d40d
commit e2aa7c2347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 10 deletions

View File

@ -624,7 +624,13 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
### 一周口碑榜
<Route author="umm233" example="/douban/movie/weekly" path="/douban/movie/weekly"/>
<Route author="umm233 nczitzk" example="/douban/movie/weekly" path="/douban/movie/weekly/:type?" :paramsDesc="['分类,可在榜单页 URL 中找到,默认为一周口碑电影榜']">
| 一周口碑电影榜 | 一周口碑剧集榜 | 华语口碑剧集榜 |
| ----------------- | -------------- | ---------------------- |
| movie_weekly_best | tv_weekly_best | tv_chinese_best_weekly |
</Route>
### 豆瓣电影分类

View File

@ -171,7 +171,7 @@ router.get('/douban/movie/playing/:score', require('./routes/douban/playing'));
router.get('/douban/movie/playing/:score/:city', require('./routes/douban/playing'));
router.get('/douban/movie/later', require('./routes/douban/later'));
router.get('/douban/movie/ustop', require('./routes/douban/ustop'));
router.get('/douban/movie/weekly', require('./routes/douban/weekly_best'));
router.get('/douban/movie/weekly/:type?', require('./routes/douban/weekly_best'));
router.get('/douban/movie/classification/:sort?/:score?/:tags?', require('./routes/douban/classification.js'));
router.get('/douban/group/:groupid', require('./routes/douban/group'));
router.get('/douban/explore', require('./routes/douban/explore'));

View File

@ -1,27 +1,38 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const type = ctx.params.type || 'movie_weekly_best';
const link = 'https://m.douban.com/movie';
const response = await got({
const apiUrl = `https://m.douban.com/rexxar/api/v2/subject_collection/${type}`;
const itemResponse = await got({
method: 'get',
url: 'https://m.douban.com/rexxar/api/v2/subject_collection/movie_weekly_best/items?start=0&count=10',
url: `${apiUrl}/items?start=0&count=10`,
headers: {
Referer: link,
},
});
const infoResponse = await got({
method: 'get',
url: apiUrl,
headers: {
Referer: link,
},
});
const data = response.data.subject_collection_items;
const data = itemResponse.data.subject_collection_items;
ctx.state.data = {
title: '豆瓣一周口碑电影榜',
link: 'https://movie.douban.com/chart',
description: '每周五更新',
title: infoResponse.data.title,
link: `https://m.douban.com/subject_collection/${type}`,
description: infoResponse.data.description,
item: data.map(({ title, info, cover, url, rating, year, release_date, null_rating_reason }) => {
item: data.map(({ title, info, cover, url, rating, year, release_date, null_rating_reason, description }) => {
const release = `${year}.${release_date}`;
const rate = rating ? `${rating.value.toFixed(1)}` : null_rating_reason;
const description = `标题:${title} <br> 影片信息:${info} <br> 上映日期:${release} <br> 评分:${rate} <br> <img src="${cover.url}">`;
description = `标题:${title} <br> 影片信息:${info} <br> 上映日期:${release} <br> 评分:${rate} <br> <img src="${cover.url}"> <p>${description}</p>`;
return {
title,