fix: douban movie allow empty/set default score 0 (#2458)

This commit is contained in:
Cloud 2019-06-22 16:57:29 +08:00 committed by DIYgod
parent 990dac8eee
commit c48ad0b377
1 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@ const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const score = parseFloat(ctx.params.score, 10);
const score = parseFloat(ctx.params.score) || 0;
const response = await got({
method: 'get',
url: `https://movie.douban.com/cinema/nowplaying/beijing`,
@ -16,7 +16,7 @@ module.exports = async (ctx) => {
.get()
.map((i) => {
const item = $(i);
const itemScore = parseFloat(item.attr('data-score'), 10);
const itemScore = parseFloat(item.attr('data-score')) || 10;
if (itemScore >= score) {
return {
title: item.attr('data-title'),
@ -31,4 +31,5 @@ module.exports = async (ctx) => {
})
.filter((item) => item),
};
ctx.state.allowEmpty = true;
};