mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
feat: added MaxNews of Dota 2 (#2176)
* feat: added MaxNews of Dota 2 * fix: CRLF -> LF
This commit is contained in:
@@ -192,3 +192,9 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
### 公告
|
||||
|
||||
<Route author="magic-akari" example="/kirara/news" path="/kirara/news"/>
|
||||
|
||||
## MaxNews
|
||||
|
||||
### Dota 2
|
||||
|
||||
<Route author="dearrrfish" example="/maxnews/dota2" path="maxnews/dota2" />
|
||||
|
||||
@@ -1310,6 +1310,9 @@ router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/categor
|
||||
router.get('/dsndsht23/:subforumid', require('./routes/dsndsht23/index'));
|
||||
router.get('/dsndsht23', require('./routes/dsndsht23/index'));
|
||||
|
||||
// MaxNews - DotA 2
|
||||
router.get('/maxnews/dota2', require('./routes/maxnews/dota2'));
|
||||
|
||||
// 数英网最新文章
|
||||
router.get('/digitaling/index', require('./routes/digitaling/index'));
|
||||
|
||||
|
||||
45
lib/routes/maxnews/dota2.js
Normal file
45
lib/routes/maxnews/dota2.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const axios = require('@/utils/axios');
|
||||
|
||||
const sourceTimezoneOffset = -8;
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://news.maxjia.com/maxnews/app/list/';
|
||||
const res = await axios.get(url);
|
||||
const articles = (res.data || {}).result || [];
|
||||
const out = await Promise.all(
|
||||
articles.map(async (article) => {
|
||||
const link = article.newUrl;
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return JSON.parse(cache);
|
||||
}
|
||||
|
||||
const guid = article.newsid;
|
||||
const title = article.title;
|
||||
const time = new Date(article.date);
|
||||
time.setTime(time.getTime() + (sourceTimezoneOffset - time.getTimezoneOffset() / 60) * 60 * 60 * 1000);
|
||||
const pubDate = time.toUTCString();
|
||||
|
||||
const detailJsonLink = article.detail_json;
|
||||
const detailRes = await axios.get(detailJsonLink);
|
||||
const description = detailRes.data.content;
|
||||
|
||||
const item = {
|
||||
title,
|
||||
description,
|
||||
pubDate,
|
||||
link,
|
||||
guid,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(item));
|
||||
|
||||
return item;
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'MaxNews - Dota 2',
|
||||
link: 'https://www.maxjia.com',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user