feat(route): add audiobar.cn 音频应用论坛 (#9063)

* add

* add audiobar

* add

* add doc

* use parseDate

* fix

* add v2

* remove old doc

* Update docs/bbs.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/audiobar/latest.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/audiobar/maintainer.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/audiobar/router.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix doc

* Update lib/v2/audiobar/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix: docs link

Co-authored-by: zhuty <zhuty@sci99.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
zxzhuty
2022-02-17 08:36:02 +08:00
committed by GitHub
co-authored by Tony zhuty
parent a3f556d4de
commit 69dcb7ec66
5 changed files with 78 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const rootUrl = 'http://www.audiobar.cn/';
module.exports = async (ctx) => {
const currentUrl = `${rootUrl}/all.php`;
const response = await got({
method: 'get',
url: currentUrl,
responseType: 'buffer',
});
const data = iconv.decode(response.data, 'gb2312');
const $ = cheerio.load(data);
const list = $('.thread_every_container_div')
.map((_, item) => {
item = $(item);
const link = item.find('.thread_subject').attr('href');
const dateStr = item.find('.atrd_span').text().slice(-26).replace(' ', '');
return {
title: item.find('.thread_subject').text().replace('\n', '').replace(' ', ''),
link: link.indexOf('http') > -1 ? link : `${rootUrl}${link}`,
pubDate: timezone(parseDate(dateStr, 'YY-M-D HH:mm'), +8),
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const detailResponsedata = iconv.decode(detailResponse.data, 'gb2312');
const content = cheerio.load(detailResponsedata);
item.description = content('.zhengwen_div').text().replace('Your browser does not support HTML5, please change another browser.', '');
return item;
})
)
);
ctx.state.data = {
title: '音频应用-最新主题',
link: currentUrl,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/latest': ['zxzhuty'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'audiobar.cn': {
_name: '音频应用',
'.': [
{
title: '最新主题',
docs: 'https://docs.rsshub.app/bbs.html#yin-pin-ying-yong',
source: ['/all.php'],
target: '/audiobar/latest',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/latest', require('./latest'));
};