${element.feed.description}
`, - pubDate: `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`, - link: `${host}/web/${link}/${element.feed.sourceID.split('/')[0]}?${video}title=${encodeURI(element.feed.seedTitle)}&remark=seed`, - }; - }) - .filter((item) => item.title !== undefined); - - ctx.state.data = { - title: `旅法师营地 - ${ctx.params.typecode === '1' ? '首页资讯' : feeds['0'].feed.seedTitle}`, - link: url, - item: items, - }; -}; diff --git a/lib/v2/lfsyd/home.js b/lib/v2/lfsyd/home.js new file mode 100644 index 00000000000000..703444adc2d71b --- /dev/null +++ b/lib/v2/lfsyd/home.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { ProcessForm, ProcessFeed } = require('./utils'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.iyingdi.com'; + const url = 'https://api.iyingdi.com/mweb/feed/recommend-content-list'; + const form = { + size: 30, + timestamp: '', + }; + const response = await got({ + method: 'post', + url, + headers: { + 'App-Udid': 'unknown', + Host: 'api.iyingdi.com', + 'Login-Token': 'nologin', + Origin: 'https://mob.iyingdi.com', + Platform: 'mweb', + Preid: '86f2007de00272e24a54831a621aecc5', + Referer: 'https://mob.iyingdi.com/', + }, + form: ProcessForm(form, 'mweb'), + }); + const { posts } = response.data; + + const articleList = posts.map((item) => ({ + title: item.post.title, + pubDate: parseDate(item.post.show_time * 1000), + link: `${rootUrl}/tz/post/${item.post.id}`, + guid: item.post.title, + postId: item.post.id, + })); + const items = await ProcessFeed(ctx.cache, articleList); + + ctx.state.data = { + title: '首页 - 旅法师营地', + link: rootUrl, + item: items, + }; +}; diff --git a/lib/v2/lfsyd/maintainer.js b/lib/v2/lfsyd/maintainer.js new file mode 100644 index 00000000000000..53e68b726e3c48 --- /dev/null +++ b/lib/v2/lfsyd/maintainer.js @@ -0,0 +1,7 @@ +// 旅法师营地 +module.exports = { + '/home': ['auto-bot-ty'], + '/old_home': ['auto-bot-ty'], + '/user/:id?': ['auto-bot-ty'], + '/tag/:tagId?': ['auto-bot-ty'], +}; diff --git a/lib/v2/lfsyd/old_home.js b/lib/v2/lfsyd/old_home.js new file mode 100644 index 00000000000000..e81cd1dfd5a6ab --- /dev/null +++ b/lib/v2/lfsyd/old_home.js @@ -0,0 +1,29 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { ProcessFeed } = require('./utils'); + +module.exports = async (ctx) => { + const limit = ctx.query.limit ?? 10; + const rootUrl = 'https://www.iyingdi.com'; + const url = `${rootUrl}/feed/list/user/v3?feedIdUp=0&feedIdDown=0&hotfeed=1&system=web`; + const { data } = await got(url); + + const articleList = data.feeds + .slice(0, limit) + .map((element) => ({ + title: element.feed.title, + pubDate: parseDate(element.feed.created * 1000), + link: `${rootUrl}/tz/post/${element.feed.sourceID}`, + guid: element.feed.title, + postId: element.feed.sourceID, + })) + .filter((item) => item.title !== undefined); + + const items = await ProcessFeed(ctx.cache, articleList); + + ctx.state.data = { + title: '旅法师营地 - 首页资讯(旧版)', + link: rootUrl, + item: items, + }; +}; diff --git a/lib/v2/lfsyd/radar.js b/lib/v2/lfsyd/radar.js new file mode 100644 index 00000000000000..fc03f91230e2e4 --- /dev/null +++ b/lib/v2/lfsyd/radar.js @@ -0,0 +1,39 @@ +module.exports = { + 'iyingdi.com': { + _name: '旅法师营地', + www: [ + { + title: '分区', + docs: 'https://docs.rsshub.app/game.html#lv-fa-shi-ying-di', + source: ['/tz/tag/:tagId'], + target: '/lfsyd/tag/:tagId', + }, + { + title: '用户发帖', + docs: 'https://docs.rsshub.app/game.html#lv-fa-shi-ying-di', + source: ['/tz/people/:id', '/tz/people/:id/*'], + target: '/lfsyd/user/:id', + }, + { + title: '首页', + docs: 'https://docs.rsshub.app/game.html#lv-fa-shi-ying-di', + source: ['/'], + target: '/lfsyd/home', + }, + { + title: '首页(旧版)', + docs: 'https://docs.rsshub.app/game.html#lv-fa-shi-ying-di', + source: ['/'], + target: '/lfsyd/old_home', + }, + ], + mob: [ + { + title: '分区(mob)', + docs: 'https://docs.rsshub.app/game.html#lv-fa-shi-ying-di', + source: ['/fine/:tagId'], + target: '/lfsyd/tag/:tagId', + }, + ], + }, +}; diff --git a/lib/v2/lfsyd/router.js b/lib/v2/lfsyd/router.js new file mode 100644 index 00000000000000..c7674d01706587 --- /dev/null +++ b/lib/v2/lfsyd/router.js @@ -0,0 +1,6 @@ +module.exports = function (router) { + router.get('/home', require('./home')); + router.get('/old_home', require('./old_home')); + router.get('/user/:id?', require('./user')); + router.get('/tag/:tagId?', require('./tag')); +}; diff --git a/lib/routes/lfsyd/tag.js b/lib/v2/lfsyd/tag.js similarity index 79% rename from lib/routes/lfsyd/tag.js rename to lib/v2/lfsyd/tag.js index a0389bfb7cb053..ee8e1a720b9d2d 100644 --- a/lib/routes/lfsyd/tag.js +++ b/lib/v2/lfsyd/tag.js @@ -1,9 +1,9 @@ const got = require('@/utils/got'); -const util = require('./utils'); const { parseDate } = require('@/utils/parse-date'); +const { ProcessForm, ProcessFeed } = require('./utils'); module.exports = async (ctx) => { - const tagId = ctx.params.tag; + const { tagId } = ctx.params; const tagList = { 17: '炉石传说', 18: '万智牌', @@ -40,9 +40,10 @@ module.exports = async (ctx) => { Platform: 'pc', Referer: `${rootUrl}/`, }, - form: util.getForm(form), + form: ProcessForm(form), }); - const list = response.data.list; + + const { list } = response.data; const tagJson = JSON.parse(list[0].feed.tag_json); const articleList = list.map((item) => ({ @@ -53,12 +54,11 @@ module.exports = async (ctx) => { postId: item.feed.source_id, })); - const items = await Promise.all(articleList.map((item) => util.ProcessFeed(ctx, item))); + const items = await ProcessFeed(ctx.cache, articleList); ctx.state.data = { - title: `${!tagName ? tagJson[0].tag : tagName} - 旅法师营地 `, + title: `${tagName || tagJson[0].tag} - 旅法师营地 `, link: `${rootUrl}/tz/tag/${tagId}`, - description: `${!tagName ? tagJson[0].tag : tagName} - 旅法师营地 `, item: items, }; }; diff --git a/lib/v2/lfsyd/templates/card.art b/lib/v2/lfsyd/templates/card.art new file mode 100644 index 00000000000000..30e812387de504 --- /dev/null +++ b/lib/v2/lfsyd/templates/card.art @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/routes/lfsyd/user.js b/lib/v2/lfsyd/user.js similarity index 76% rename from lib/routes/lfsyd/user.js rename to lib/v2/lfsyd/user.js index 2fbbe1f40f46f9..023789937b2323 100644 --- a/lib/routes/lfsyd/user.js +++ b/lib/v2/lfsyd/user.js @@ -1,6 +1,6 @@ const got = require('@/utils/got'); -const util = require('./utils'); const { parseDate } = require('@/utils/parse-date'); +const { ProcessForm, ProcessFeed } = require('./utils'); module.exports = async (ctx) => { const id = ctx.params.id; @@ -24,12 +24,13 @@ module.exports = async (ctx) => { Platform: 'pc', Referer: `${rootUrl}/tz/people/${id}/postList`, }, - form: util.getForm(form), + form: ProcessForm(form), }); - const list = response.data.data; - const nickname = list[0].author.nickname; - const articleList = list.map((item) => ({ + const { data } = response.data; + const { nickname } = data[0].author; + + const articleList = data.map((item) => ({ title: item.event_data.title, pubDate: parseDate(item.event_data.show_time * 1000), link: `${rootUrl}/tz/post/${item.event_data.post_id}`, @@ -37,12 +38,11 @@ module.exports = async (ctx) => { postId: item.event_data.post_id, })); - const items = await Promise.all(articleList.map((item) => util.ProcessFeed(ctx, item))); + const items = await ProcessFeed(ctx.cache, articleList); ctx.state.data = { title: `${nickname} - 旅法师营地 `, link: `${rootUrl}/tz/people/${id}`, - description: `${nickname} - 旅法师营地`, item: items, }; }; diff --git a/lib/routes/lfsyd/utils.js b/lib/v2/lfsyd/utils.js similarity index 50% rename from lib/routes/lfsyd/utils.js rename to lib/v2/lfsyd/utils.js index d21e9e7aec2127..c65df4e159318c 100644 --- a/lib/routes/lfsyd/utils.js +++ b/lib/v2/lfsyd/utils.js @@ -1,34 +1,42 @@ const cheerio = require('cheerio'); const got = require('@/utils/got'); const md5 = require('@/utils/md5'); +const path = require('path'); +const { art } = require('@/utils/render'); const rootUrl = 'https://www.iyingdi.com'; -const ProcessFeed = async (ctx, item) => { - const infoUrL = 'https://api.iyingdi.com/web/post/info'; - const infoForm = { - post_id: item.postId, - 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(infoForm), - }); - return cleanHtml(JSON.parse(response.body).post.content); - }); - item.description = description; - delete item.postId; - return item; +const infoUrL = 'https://api.iyingdi.com/web/post/info'; + +const ProcessFeed = async (cache, articleList) => { + const items = await Promise.all( + articleList.map((item) => + cache.tryGet(item.link, async () => { + const infoForm = { + post_id: item.postId, + timestamp: '', + }; + const { body } = await got({ + method: 'post', + url: infoUrL, + headers: { + Host: 'api.iyingdi.com', + 'Login-Token': 'nologin', + Origin: rootUrl, + Platform: 'pc', + Referer: `${rootUrl}/`, + }, + form: ProcessForm(infoForm), + }); + item.description = cleanHtml(JSON.parse(body).post.content); + return item; + }) + ) + ); + + return items; }; -const getForm = function (form, type) { + +const ProcessForm = (form, type) => { const key = type ? '8a11ed3712b699e749185674f1dc20b4' : 'b8d5b38577b8bb382b0c783b474b95f9'; form.key = key; form.timestamp = Math.floor(new Date().getTime() / 1000); @@ -37,16 +45,23 @@ const getForm = function (form, type) { return form; }; -const cleanHtml = function (htmlString) { +const cleanHtml = (htmlString) => { const regex = new RegExp('(|