forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): 营地改版,换用新接口 (DIYgod#7464)
Co-authored-by: auto-bot-ty <auto-bot-ty@git@com>
- Loading branch information
1 parent
d5d81f8
commit 43cda0b
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const got = require('@/utils/got'); | ||
const util = require('./utils'); | ||
const timezone = require('@/utils/timezone'); | ||
const parseDate = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const tag_id = ctx.params.tag; | ||
const tag_list = { | ||
17: '炉石传说', | ||
18: '万智牌', | ||
16: '游戏王', | ||
19: '昆特牌', | ||
20: '影之诗', | ||
329: '符文之地传奇', | ||
221: '阴阳师百闻牌', | ||
112: '英雄联盟', | ||
389: '电子游戏', | ||
24: '桌面游戏', | ||
102: '卡牌游戏', | ||
23: '玩家杂谈', | ||
117: '二次元', | ||
}; | ||
const tag_name = tag_list[tag_id]; | ||
const rootUrl = 'https://www.iyingdi.com'; | ||
const tagUrl = 'https://api.iyingdi.com/web/feed/tag-content-list'; | ||
const form = { | ||
page: 1, | ||
size: 30, | ||
tag_id: tag_id, | ||
timestamp: '', | ||
version: 0, | ||
}; | ||
|
||
const response = await got({ | ||
method: 'post', | ||
url: tagUrl, | ||
headers: { | ||
Host: 'api.iyingdi.com', | ||
'Login-Token': 'nologin', | ||
Origin: rootUrl, | ||
Platform: 'pc', | ||
Referer: `${rootUrl}/`, | ||
}, | ||
form: util.getForm(form), | ||
}); | ||
const list = response.data.list; | ||
const tag_json = JSON.parse(list[0].feed.tag_json); | ||
|
||
const articleList = list.map((item) => ({ | ||
title: item.feed.title, | ||
pubDate: timezone(parseDate(item.feed.show_time * 1000), +8), | ||
link: `${rootUrl}/tz/post/${item.feed.source_id}`, | ||
guid: item.feed.title, | ||
post_id: item.feed.source_id, | ||
})); | ||
|
||
const items = await Promise.all(articleList.map(async (item) => await util.ProcessFeed(ctx, item))); | ||
|
||
ctx.state.data = { | ||
title: `${!tag_name ? tag_json[0].tag : tag_name} - 旅法师营地 `, | ||
link: `${rootUrl}/tz/tag/${tag_id}`, | ||
description: `${!tag_name ? tag_json[0].tag : tag_name} - 旅法师营地 `, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const got = require('@/utils/got'); | ||
const md5 = require('@/utils/md5'); | ||
|
||
const ProcessFeed = async (ctx, item) => { | ||
const infoUrL = 'https://api.iyingdi.com/web/post/info'; | ||
const rootUrl = 'https://www.iyingdi.com'; | ||
const info_form = { | ||
post_id: item.post_id, | ||
timestamp: '', | ||
}; | ||
|
||
const description = await ctx.cache.tryGet(item.link, async () => { | ||
const response = await got({ | ||
method: 'post', | ||
url: infoUrL, | ||
headers: { | ||
Host: 'api.iyingdi.com', | ||
'Login-Token': 'nologin', | ||
Origin: rootUrl, | ||
Platform: 'pc', | ||
Referer: `${rootUrl}/`, | ||
}, | ||
form: getForm(info_form), | ||
}); | ||
const content_body = JSON.parse(response.body); | ||
return content_body.post.content; | ||
}); | ||
|
||
item.description = description; | ||
delete item.post_id; | ||
return item; | ||
}; | ||
|
||
const getForm = function (form) { | ||
const key = 'b8d5b38577b8bb382b0c783b474b95f9'; | ||
form.key = key; | ||
form.timestamp = Math.floor(new Date().getTime() / 1000); | ||
form.sign = md5(new URLSearchParams(form).toString()); | ||
delete form.key; | ||
return form; | ||
}; | ||
module.exports = { | ||
getForm, | ||
ProcessFeed, | ||
}; |