From 7659ba514b3e2932bdc7d525fae483d7b2bc960a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=92=E8=B0=9C?= <2503894740@QQ.COM> Date: Sun, 1 Mar 2020 13:27:41 +0800 Subject: [PATCH] feat: BOOKSOURCE.STORE (#4129) --- docs/other.md | 17 ++++++++++ docs/university.md | 8 ++--- lib/router.js | 9 +++-- lib/routes/booksource/index.js | 22 +++++++++++++ lib/routes/houmo/booksource.js | 51 ----------------------------- lib/routes/ku/index.js | 31 ++++++++++++++++++ lib/routes/universities/lit/jwc.js | 1 + lib/routes/universities/lit/tw.js | 3 ++ lib/routes/universities/lit/xwzx.js | 5 +++ 9 files changed, 89 insertions(+), 58 deletions(-) create mode 100644 lib/routes/booksource/index.js delete mode 100644 lib/routes/houmo/booksource.js create mode 100644 lib/routes/ku/index.js diff --git a/docs/other.md b/docs/other.md index 21d38d6e05..bf9f5cd749 100644 --- a/docs/other.md +++ b/docs/other.md @@ -25,6 +25,12 @@ pageClass: routes +## BOOKSOURCE.STORE + +### 书源仓库更新 + + + ## checkee.info ### 美国签证 check 动态 @@ -483,6 +489,17 @@ type 为 all 时,category 参数不支持 cost 和 free +## 源仓库 + +### 源仓库更新 + + +| 阅读 | 异次元 | 海阔 | +| ---- | ----- | ---- | +| yuedu | yiciyuan | haikuo | + + + ## 远程.work ### 远程.work 招聘信息 diff --git a/docs/university.md b/docs/university.md index dd60619169..8a0a2fd760 100644 --- a/docs/university.md +++ b/docs/university.md @@ -52,7 +52,7 @@ pageClass: routes ### 每周一推 - 中国政治学研究中心 - + ### 生命科学学院近期讲座 @@ -546,11 +546,11 @@ category 列表: ### 教务处 - + ### 新闻中心 - + | 全部 | 公告通知 | 新闻快讯 | 学术信息 | 媒体新闻 | | ---- | -------- | -------- | -------- | -------- | @@ -560,7 +560,7 @@ category 列表: ### 团委 - + | 全部 | 团内通知 | 青年快讯 | | ---- | -------- | -------- | diff --git a/lib/router.js b/lib/router.js index de884aaeb0..3fc9227c60 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1887,9 +1887,6 @@ router.get('/cfan/news', require('./routes/cfan/news')); // 搜狐 - 搜狐号 router.get('/sohu/mp/:id', require('./routes/sohu/mp')); -// 厚墨书源索引 -router.get('/houmo/:code?', require('./routes/houmo/booksource')); - // 腾讯企鹅号 router.get('/tencent/news/author/:mid', require('./routes/tencent/news/author')); @@ -2307,6 +2304,12 @@ router.get('/wolley/host/:host', require('./routes/wolley/host')); // 西安交大 router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean')); +// booksource +router.get('/booksource', require('./routes/booksource/index')); + +// ku +router.get('/ku/:name?', require('./routes/ku/index')); + // 我有一片芝麻地 router.get('/blogs/hedwig/:type', require('./routes/blogs/hedwig')); diff --git a/lib/routes/booksource/index.js b/lib/routes/booksource/index.js new file mode 100644 index 0000000000..285b6ca105 --- /dev/null +++ b/lib/routes/booksource/index.js @@ -0,0 +1,22 @@ +const got = require('@/utils/got'); + +const api = 'http://api.booksource.store/repo/list?sort=update_time&page=1&size=10'; +module.exports = async (ctx) => { + const response = await got.get(api); + const data = response.data; + ctx.state.data = { + title: `BOOKSOURCE.STORE`, + link: 'http://booksource.store/', + description: `BOOKSOURCE.STORE RSS`, + item: data.map((item) => ({ + title: `${item.name} - v${item.version}`, + guid: item.url, + author: item.owner, + pubDate: item.update_time, + description: `

网址: ${item.url}

+

作者: ${item.owner}

+

更新时间: ${item.update_time}

+

${item.rank || item.account ? '其它:' : ''} ${item.rank === true ? '排行榜' : ''} ${item.account === true ? '网站账号登录' : ''}

`, + })), + }; +}; diff --git a/lib/routes/houmo/booksource.js b/lib/routes/houmo/booksource.js deleted file mode 100644 index 47f8c3a86c..0000000000 --- a/lib/routes/houmo/booksource.js +++ /dev/null @@ -1,51 +0,0 @@ -const got = require('@/utils/got'); - -const url = 'http://qingmo.zohar.space/git/repository.json'; -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: url, - }); - - const code = ctx.params.code; - - const list = response.data.list; - - if (!code) { - ctx.state.data = { - title: `BookSource`, - link: url, - description: `厚墨书源索引`, - item: list.map((item) => { - const author = item.name.match(/(.*?)-/g)[0].replace('-', ''); - return { - title: item.name + ` v` + item.version, - description: `

作者: ${author}

暗码: ${item.code}

tg群: @deepinkapp

论坛地址: https://andyt.cn/

`, - link: item.url.replace('real site => ', ''), - author: author, - }; - }), - }; - } else { - const items = []; - list.map((item) => { - const author = item.name.match(/(.*?)-/g)[0].replace('-', ''); - if (item.code === code) { - items.push({ - title: item.name + ` v` + item.version, - description: `

作者: ${author}

tg群: @deepinkapp

论坛地址: https://andyt.cn/

`, - link: item.url.replace('real site => ', ''), - author: author, - }); - } - return 0; - }); - - ctx.state.data = { - title: `${code} - BookSource`, - link: url, - description: `暗码: ${code} - 厚墨书源索引`, - item: items, - }; - } -}; diff --git a/lib/routes/ku/index.js b/lib/routes/ku/index.js new file mode 100644 index 0000000000..ad6863517c --- /dev/null +++ b/lib/routes/ku/index.js @@ -0,0 +1,31 @@ +const got = require('@/utils/got'); + +const nameProps = { + yuedu: '阅读', + yiciyuan: '异次元', + haikuo: '海阔', +}; + +module.exports = async (ctx) => { + const name = ctx.params.name || 'yuedu'; + const api = `http://ku.mumuceo.com/${name}/index/getlist`; + const response = await got.post(api, { + json: { + page: 1, + limit: 10, + }, + }); + const data = response.data.data; + ctx.state.data = { + title: `${nameProps[name]} - 源仓库`, + link: 'http://ku.mumuceo.com/', + description: `源仓库 - ${nameProps[name]} RSS`, + item: data.map((item) => ({ + title: item.yuansite, + link: `http://ku.mumuceo.com/${name}/detail/index/id/${item.id}.html`, + author: item.username, + pubDate: item.time, + description: item.yuan, + })), + }; +}; diff --git a/lib/routes/universities/lit/jwc.js b/lib/routes/universities/lit/jwc.js index be67b23af5..9429535ab4 100644 --- a/lib/routes/universities/lit/jwc.js +++ b/lib/routes/universities/lit/jwc.js @@ -25,6 +25,7 @@ module.exports = async (ctx) => { $('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove(); + $('img[src="/system/resource/images/fileTypeImages/icon_pdf.gif"]').remove(); const description = $('article.entry-content').html(); const pubDate = $('time').text(); diff --git a/lib/routes/universities/lit/tw.js b/lib/routes/universities/lit/tw.js index 2f9b09f80d..1be9df27b2 100644 --- a/lib/routes/universities/lit/tw.js +++ b/lib/routes/universities/lit/tw.js @@ -29,9 +29,12 @@ module.exports = async (ctx) => { const other = await ctx.cache.tryGet(link, async () => { const result = await got.get(link); const $ = cheerio.load(result.data); + $('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove(); + $('img[src="/system/resource/images/fileTypeImages/icon_pdf.gif"]').remove(); + const description = $('#textarea').html(); const title = $('article > section > form > h2').text(); return { diff --git a/lib/routes/universities/lit/xwzx.js b/lib/routes/universities/lit/xwzx.js index 7d69d82969..83e87c3a0c 100644 --- a/lib/routes/universities/lit/xwzx.js +++ b/lib/routes/universities/lit/xwzx.js @@ -35,6 +35,11 @@ module.exports = async (ctx) => { $('img[src="/system/resource/images/fileTypeImages/icon_xls.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_doc.gif"]').remove(); $('img[src="/system/resource/images/fileTypeImages/icon_ppt.gif"]').remove(); + $('img[src="/system/resource/images/fileTypeImages/icon_pdf.gif"]').remove(); + + $('.nr_text') + .find('hr') + .remove(); const delp = $('.nr_text').find('p'); delp.eq(-1).remove(); delp.eq(-2).remove();