diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index bf39b7010c..2353acfdc6 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -19,16 +19,21 @@ module.exports = async (ctx, next) => { const tasks = ctx.state.data.item.map(async (item) => { const { link, author, description } = item; const parsed_result = await ctx.cache.tryGet(`mercury-cache-${link}`, async () => { - const res = await got(link); - const $ = cheerio.load(res.data); - const result = await mercury_parser.parse(link, { - html: $.html(), - }); - return result; + // if parser failed, return default description and not report error + try { + const res = await got(link); + const $ = cheerio.load(res.data); + const result = await mercury_parser.parse(link, { + html: $.html(), + }); + return result; + } catch (e) { + // no-empty + } }); - item.author = author || parsed_result.author; - item.description = parsed_result.content || description; + item.author = author || (parsed_result ? parsed_result.author : ''); + item.description = parsed_result ? parsed_result.content : description; }); await Promise.all(tasks); } diff --git a/lib/routes/douban/people/status.js b/lib/routes/douban/people/status.js index 0b58c3feeb..a87137b334 100644 --- a/lib/routes/douban/people/status.js +++ b/lib/routes/douban/people/status.js @@ -12,11 +12,18 @@ function getContentByActivity(status) { }); break; case '转发': - description = getContentByActivity(status.reshared_status).title; - title = `${status.author.name} ${status.activity} ${status.reshared_status.author.name} 的广播:${status.reshared_status.text}`; - status.reshared_status.images.forEach((image) => { - description += `

`; - }); + description = `${status.text}
`; + if (status.reshared_status.deleted) { + title = `${status.author.name} ${status.activity} 广播:原动态已被发布者删除`; + description += `原动态已被发布者删除`; + } else { + description += getContentByActivity(status.reshared_status).title; + title = `${status.author.name} ${status.activity} ${status.reshared_status.author.name} 的广播:${status.reshared_status.text}`; + status.reshared_status.images.forEach((image) => { + description += `

`; + }); + } + break; default: if (status.card) { @@ -44,19 +51,22 @@ module.exports = async (ctx) => { Referer: `https://m.douban.com/people/${userid}/statuses`, }, }); + const items = response.data.items; ctx.state.data = { title: `豆瓣广播-${userid}`, link: `https://m.douban.com/people/${userid}/statuses`, - item: items.map((item) => { - const r = getContentByActivity(item.status); - return { - title: r.title, - link: item.status.sharing_url, - pubDate: item.status.create_time, - description: r.description, - }; - }), + item: items + .filter((item) => !item.deleted) + .map((item) => { + const r = getContentByActivity(item.status); + return { + title: r.title, + link: item.status.sharing_url, + pubDate: item.status.create_time, + description: r.description, + }; + }), }; }; diff --git a/package.json b/package.json index 6d91e7169a..8f2da4f39f 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,12 @@ "@vuepress/plugin-pwa": "1.0.3", "cross-env": "5.2.1", "eslint": "6.3.0", - "eslint-config-prettier": "6.1.0", + "eslint-config-prettier": "6.2.0", "eslint-plugin-prettier": "3.1.0", "jest": "24.9.0", "mockdate": "2.0.5", "nock": "11.3.2", - "nodemon": "1.19.1", + "nodemon": "1.19.2", "pinyin": "2.9.0", "prettier": "1.18.2", "prettier-check": "2.0.0", diff --git a/yarn.lock b/yarn.lock index bfe35ed14e..e214172d1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3896,10 +3896,10 @@ escodegen@^1.8.1, escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.1.0.tgz#e6f678ba367fbd1273998d5510f76f004e9dce7b" - integrity sha512-k9fny9sPjIBQ2ftFTesJV21Rg4R/7a7t7LCtZVrYQiHEp8Nnuk3EGaDmsKSAnsPj0BYcgB2zxzHa2NTkIxcOLg== +eslint-config-prettier@6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.2.0.tgz#80e0b8714e3f6868c4ac2a25fbf39c02e73527a7" + integrity sha512-VLsgK/D+S/FEsda7Um1+N8FThec6LqE3vhcMyp8mlmto97y3fGf3DX7byJexGuOb1QY0Z/zz222U5t+xSfcZDQ== dependencies: get-stdin "^6.0.0" @@ -7458,10 +7458,10 @@ nodemailer@6.1.1: resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.1.1.tgz#09e88ef4b3646f01089c5d84d007b872141fb575" integrity sha1-CeiO9LNkbwEInF2E0Ae4chQftXU= -nodemon@1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.19.1.tgz#576f0aad0f863aabf8c48517f6192ff987cd5071" - integrity sha512-/DXLzd/GhiaDXXbGId5BzxP1GlsqtMGM9zTmkWrgXtSqjKmGSbLicM/oAy4FR0YWm14jCHRwnR31AHS2dYFHrg== +nodemon@1.19.2: + version "1.19.2" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.19.2.tgz#b0975147dc99b3761ceb595b3f9277084931dcc0" + integrity sha512-hRLYaw5Ihyw9zK7NF+9EUzVyS6Cvgc14yh8CAYr38tPxJa6UrOxwAQ351GwrgoanHCF0FalQFn6w5eoX/LGdJw== dependencies: chokidar "^2.1.5" debug "^3.1.0"