From 72724419c22c5e42336816154eb462dec8aba28a Mon Sep 17 00:00:00 2001 From: ZhenHappy Date: Thu, 24 Feb 2022 19:09:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20A=E5=A7=90=E5=88=86?= =?UTF-8?q?=E4=BA=AB=20(#9028)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add abskoop * feat(route): refactor to v2 script * feat(route): fix timezone error * feat(route): fix art template raw output don't working * feat(route): Suggested change * feat(route): Suggested change * feat(route): add radar.js --- docs/multimedia.md | 4 ++ lib/v2/abskoop/index.js | 52 ++++++++++++++++++++++++ lib/v2/abskoop/maintainer.js | 3 ++ lib/v2/abskoop/radar.js | 13 ++++++ lib/v2/abskoop/router.js | 3 ++ lib/v2/abskoop/templates/description.art | 3 ++ 6 files changed, 78 insertions(+) create mode 100644 lib/v2/abskoop/index.js create mode 100644 lib/v2/abskoop/maintainer.js create mode 100644 lib/v2/abskoop/radar.js create mode 100644 lib/v2/abskoop/router.js create mode 100644 lib/v2/abskoop/templates/description.art diff --git a/docs/multimedia.md b/docs/multimedia.md index e54c9326d5..7ab091dd8a 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -156,6 +156,10 @@ pageClass: routes +## A 姐分享 + + + ## AcFun 见 [#AcFun](/anime.html#acfun) diff --git a/lib/v2/abskoop/index.js b/lib/v2/abskoop/index.js new file mode 100644 index 0000000000..aa462e864e --- /dev/null +++ b/lib/v2/abskoop/index.js @@ -0,0 +1,52 @@ +const path = require('path'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://www.abskoop.com/archives/', + }); + + const $list = cheerio.load(response.data); + const list = $list('article li') + .slice(0, 20) + .map(function () { + return { + link: $list(this).find('a').attr('href'), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ method: 'get', url: item.link }); + const $detail = cheerio.load(detailResponse.data); + $detail('article .entry-content a').each(function () { + if ($detail(this).find('img').length > 0) { + $detail(this).replaceWith(``); + } + }); + const desc = []; + $detail('article .entry-content > p').each(function () { + desc.push($detail(this).html()); + }); + item.title = $detail('article h1.entry-title').text(); + item.description = art(path.join(__dirname, 'templates/description.art'), { desc }); + item.pubDate = timezone($detail('article time').attr('datetime'), -8); + return item; + }) + ) + ); + + ctx.state.data = { + title: 'ahhhhfs - A姐分享', + link: 'https://www.abskoop.com', + description: + 'A姐分享,分享各种网络云盘资源、BT种子、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。', + item: items, + }; +}; diff --git a/lib/v2/abskoop/maintainer.js b/lib/v2/abskoop/maintainer.js new file mode 100644 index 0000000000..dbec125b1f --- /dev/null +++ b/lib/v2/abskoop/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['zhenhappy'], +}; diff --git a/lib/v2/abskoop/radar.js b/lib/v2/abskoop/radar.js new file mode 100644 index 0000000000..4853ed992d --- /dev/null +++ b/lib/v2/abskoop/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'abskoop.com': { + _name: 'A姐分享', + '.': [ + { + title: '存档列表', + docs: 'https://docs.rsshub.app/multimedia.html#abskoop', + source: ['/archives'], + target: '/abskoop', + }, + ], + }, +}; diff --git a/lib/v2/abskoop/router.js b/lib/v2/abskoop/router.js new file mode 100644 index 0000000000..20c52b09d7 --- /dev/null +++ b/lib/v2/abskoop/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./index')); +}; diff --git a/lib/v2/abskoop/templates/description.art b/lib/v2/abskoop/templates/description.art new file mode 100644 index 0000000000..4594e97993 --- /dev/null +++ b/lib/v2/abskoop/templates/description.art @@ -0,0 +1,3 @@ +{{each desc}} +

{{@ $value}}

+{{/each}}