mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 希望之声 (#9285)
* feat(route): add 希望之声 * fix(route): change timezone
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const host = 'https://www.soundofhope.org';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channel = ctx.params.channel;
|
||||
const id = ctx.params.id;
|
||||
const url = `${host}/${channel}/${id}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('div.left > nav').text().split('/').slice(1).join('');
|
||||
const list = $('div.item')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('div.title').text(),
|
||||
link: new URL($(item).find('a').attr('href'), host).href,
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('div.Content__Wrapper-sc-1bvya0-0').html();
|
||||
item.pubDate = timezone(parseDate(content('div.date').text(), 'YYYY.M.D HH:mm'), -8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `希望之声 - ${title}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:channel/:id': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'soundofhope.org': {
|
||||
_name: '希望之声',
|
||||
'.': [
|
||||
{
|
||||
title: '频道',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#xi-wang-zhi-sheng',
|
||||
source: ['/:channel/:id'],
|
||||
target: '/soundofhope/:channel/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:channel/:id', require('./channel'));
|
||||
};
|
||||
Reference in New Issue
Block a user