mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 02:08:55 +08:00
feat: add 篝火营地 (#2786)
This commit is contained in:
@@ -141,6 +141,22 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
|
||||
<Route author="whtsky" example="/steamgifts/discussions" path="/steamgifts/discussions/:category?" :paramsDesc="['分类名称,默认为All']"/>
|
||||
|
||||
## 篝火营地
|
||||
|
||||
### 游戏资讯
|
||||
|
||||
<Route author="sintak" example="/gouhuo/news/switch" path="/gouhuo/news/:category" :paramsDesc="['资讯类型']">
|
||||
|
||||
| 精选 | 海外 | 原创 | PS4 | Xboxone | PC | Switch | 掌机 | 手游 | 新闻 | 评测 | 文化 | 视频 | 音频 | 折扣 |
|
||||
| ---------- | -------- | ------- | --- | ------- | --- | ------ | -------- | ---------- | ---- | ------ | ------- | ----- | ----- | -------- |
|
||||
| choiceness | overseas | orignal | ps4 | xboxone | pc | switch | handheld | mobilegame | news | review | culture | video | audio | discount |
|
||||
|
||||
</Route>
|
||||
|
||||
### 游戏攻略
|
||||
|
||||
<Route author="sintak" example="/gouhuo/strategy" path="/gouhuo/strategy"/>
|
||||
|
||||
## 怪物猎人
|
||||
|
||||
### 更新
|
||||
|
||||
@@ -1626,4 +1626,8 @@ router.get('/pingwest/user/:uid/:type?', require('./routes/pingwest/user'));
|
||||
// Hanime
|
||||
router.get('/hanime/video', require('./routes/hanime/video'));
|
||||
|
||||
// 篝火营地
|
||||
router.get('/gouhuo/news/:category', require('./routes/gouhuo'));
|
||||
router.get('/gouhuo/strategy', require('./routes/gouhuo/strategy'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const self = {
|
||||
_getProfile: async (ctx) => {
|
||||
const key = 'gouhuo-profile';
|
||||
let profile = await ctx.cache.get(key);
|
||||
if (!profile) {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://gouhuo.qq.com/`,
|
||||
headers: {
|
||||
Referer: `https://gouhuo.qq.com/`,
|
||||
},
|
||||
});
|
||||
const body = response.data;
|
||||
const $ = cheerio.load(body);
|
||||
|
||||
// eslint-disable-next-line no-eval
|
||||
const obj = eval(body.match(/(?<=<script>\s*window\.__NUXT__=)[\s\S]*?(?=<\/script>)/g)[0]);
|
||||
const tabNameMapping = {};
|
||||
for (const item of obj.data[0].tabList) {
|
||||
tabNameMapping[item.tab_id] = item.tab_name;
|
||||
}
|
||||
const title = $('title')
|
||||
.text()
|
||||
.split('-')[0]
|
||||
.trim();
|
||||
const description = $('title')
|
||||
.text()
|
||||
.split('-')[1]
|
||||
.trim();
|
||||
|
||||
profile = JSON.stringify({
|
||||
title: title,
|
||||
description: description,
|
||||
tabNameMapping: tabNameMapping,
|
||||
});
|
||||
|
||||
ctx.cache.set(key, profile);
|
||||
}
|
||||
return JSON.parse(profile);
|
||||
},
|
||||
getStaffs: async (ctx, tabId) => {
|
||||
const profile = await self._getProfile(ctx);
|
||||
return [profile.title, profile.description, profile.tabNameMapping[tabId]];
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = self;
|
||||
@@ -0,0 +1,62 @@
|
||||
const got = require('@/utils/got');
|
||||
const cache = require('./cache');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category;
|
||||
|
||||
const tabIdMapping = {
|
||||
choiceness: '1_110',
|
||||
overseas: '1_108',
|
||||
orignal: '1_109',
|
||||
ps4: '2_5',
|
||||
xboxone: '2_13',
|
||||
pc: '2_1',
|
||||
switch: '2_30',
|
||||
handheld: '3_1',
|
||||
mobilegame: '3_2',
|
||||
news: '1_101',
|
||||
review: '1_104',
|
||||
culture: '1_103',
|
||||
video: '1_102',
|
||||
audio: '1_107',
|
||||
discount: '1_120',
|
||||
};
|
||||
const tabId = (() => {
|
||||
if (tabIdMapping[category]) {
|
||||
return tabIdMapping[category];
|
||||
} else {
|
||||
throw Error('Unknow route.');
|
||||
}
|
||||
})();
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://gouhuo.qq.com/content/getHomeMainContent?tabId=${tabId}`,
|
||||
headers: {
|
||||
Referer: `https://gouhuo.qq.com/`,
|
||||
},
|
||||
});
|
||||
const list = response.data.data;
|
||||
|
||||
const staffs = await cache.getStaffs(ctx, tabId);
|
||||
const title = staffs[0];
|
||||
const description = staffs[1];
|
||||
const tabName = staffs[2];
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title} ${tabName}`,
|
||||
link: `https://gouhuo.qq.com/`,
|
||||
description: description,
|
||||
item:
|
||||
list &&
|
||||
list.map((item) => {
|
||||
const single = {
|
||||
title: item.title,
|
||||
description: `${item.title}<br><img referrerpolicy="no-referrer" src="${item.img_url}">`, // Get fulltext manually if needs be. Snippet like: $('.widget-article').first().html();
|
||||
pubDate: new Date(item.publish_ts * 1000).toUTCString(),
|
||||
link: item.link,
|
||||
};
|
||||
return single;
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://gouhuo.qq.com';
|
||||
const url = `${baseUrl}/guide`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
Referer: `https://gouhuo.qq.com/`,
|
||||
},
|
||||
});
|
||||
const body = response.data;
|
||||
const $ = cheerio.load(body);
|
||||
|
||||
// eslint-disable-next-line no-eval
|
||||
const obj = eval(body.match(/(?<=<script>\s*window\.__NUXT__=)[\s\S]*?(?=<\/script>)/g)[0]);
|
||||
const items = obj.data[0].new_topic_list.map((item) => {
|
||||
const img_url = item.media_list && item.media_list[0].img_url;
|
||||
const single = {
|
||||
title: item.title,
|
||||
description: `${item.summary}<br><img referrerpolicy="no-referrer" src="${img_url}">`,
|
||||
pubDate: new Date(item.edit_time * 1000).toUTCString(),
|
||||
link: `${url}/detail/${item.topic_id}`,
|
||||
};
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title')
|
||||
.text()
|
||||
.split('_')[0],
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user