Files
RSSHub/lib/v2/oeeee/web.js
T
2024-02-28 19:40:21 +08:00

38 lines
1.3 KiB
JavaScript

import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('./utils');
import { art } from '@/utils/render';
import * as path from 'node:path';
module.exports = async (ctx) => {
const channel = ctx.req.param('channel') ?? 0;
const currentUrl = `https://www.oeeee.com/api/channel.php?m=Js4channelNews&a=newLatest&cid=${channel}`;
const { data: response } = await got(currentUrl);
const list = response.data.map((item) => ({
title: '【' + item.channel_name + '】' + item.title,
description: art(path.join(__dirname, 'templates/description.art'), {
thumb: item.img,
description: item.summary,
}),
pubDate: timezone(parseDate(item.datetime), +8),
link: item.linkurl,
author: item.author,
// channelName: item.channel_name,
channelEname: item.channel_ename,
}));
const channelEname = list[1] ? list[1].channelEname : '';
const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `南方都市报奥一网`,
link: `https://www.oeeee.com/api/channel.php?s=/index/index/channel/${channelEname}`,
item: items,
});
};