From fdbfc89cc0033f76af5fdd85c74880a75eb23c5c Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 8 Mar 2020 03:00:15 +0800 Subject: [PATCH] feat: optimize hpoi user --- docs/anime.md | 8 ++++---- lib/routes/hpoi/user.js | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/anime.md b/docs/anime.md index 6a78e104e9..a3fde6d042 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -141,11 +141,11 @@ pageClass: routes ### 用户动态 - + -| 想买的手办 | 预定的手办 | 已入的手办 | -| ---------- | ---------- | ---------- | -| want | preorder | buy | +| 想买 | 预定 | 已入 | 关注 | 有过 | +| ---- | -------- | ---- | ---- | ------ | +| want | preorder | buy | care | resell | diff --git a/lib/routes/hpoi/user.js b/lib/routes/hpoi/user.js index 558a21f547..abc52cc1e2 100644 --- a/lib/routes/hpoi/user.js +++ b/lib/routes/hpoi/user.js @@ -2,20 +2,11 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const root_url = 'https://www.hpoi.net'; -const caties = { - want: '想买的手办', - preorder: '预定的手办', - buy: '已入的手办', -}; module.exports = async (ctx) => { const { user_id, caty } = ctx.params; - let title = caties[caty]; - if (!title) { - throw Error('Bad category. See https://docs.rsshub.app/anime.html#hpoi-shou-ban-wei-ji'); - } - const url = `${root_url}/user/${user_id}/hobby?order=actionDate&favState=${caty}&view=5&category=100&sortType=1`; + const url = `${root_url}/user/${user_id}/hobby?order=actionDate&favState=${caty}&view=5&category=100&sortType=2`; const response = await got({ method: 'get', url: url, @@ -29,13 +20,24 @@ module.exports = async (ctx) => { const a = item.find('div.list-5-right > a.action-title'); return { title: a.text(), - link: a.attr('href'), - description: `

${a.text()}

`, + link: 'https://www.hpoi.net/' + a.attr('href'), + description: `
制作:${item + .find('.badge') + .eq(0) + .text()}
发售:${item + .find('.badge') + .eq(1) + .text()}`, }; }) .get(); - title = $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + title; + const title = + $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + + $('.navbar-nav .active') + .eq(0) + .text() + + '的手办'; ctx.state.data = { title: title,