feat(route): add A姐分享 (#9028)

* 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
This commit is contained in:
ZhenHappy 2022-02-24 19:09:46 +08:00 committed by GitHub
parent 802b67fcbb
commit 72724419c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 0 deletions

View File

@ -156,6 +156,10 @@ pageClass: routes
<Route author="Ji4n1ng" example="/99percentinvisible/transcript" path="/99percentinvisible/transcript"/>
## A 姐分享
<Route author="zhenhappy" example="/abskoop" path="/abskoop"/>
## AcFun
见 [#AcFun](/anime.html#acfun)

52
lib/v2/abskoop/index.js Normal file
View File

@ -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(`<img src=${$detail(this).attr('href')}>`);
}
});
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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/': ['zhenhappy'],
};

13
lib/v2/abskoop/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'abskoop.com': {
_name: 'A姐分享',
'.': [
{
title: '存档列表',
docs: 'https://docs.rsshub.app/multimedia.html#abskoop',
source: ['/archives'],
target: '/abskoop',
},
],
},
};

3
lib/v2/abskoop/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/', require('./index'));
};

View File

@ -0,0 +1,3 @@
{{each desc}}
<p>{{@ $value}}</p>
{{/each}}