fix: douban movie allow empty/set default score 0 (#2458)
This commit is contained in:
parent
990dac8eee
commit
c48ad0b377
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue