Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route)(v2): add 旅法师营地首页 #8350

Merged
merged 4 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,17 @@ Steam 新闻中心支持官方的 RSS 订阅:

## 旅法师营地

### 首页

<Route author="auto-bot-ty" example="/lfsyd/home" path="/lfsyd/home" radar="1" rssbud="1"/>

### 首页(旧版)

<Route author="auto-bot-ty" example="/lfsyd/old_home" path="/lfsyd/old_home" radar="1" rssbud="1"/>

### 分区

<Route author="auto-bot-ty" example="/lfsyd/tag/17" path="/lfsyd/tag/:tag" :paramsDesc="['订阅分区类型']" radar="1" rssbud="1">
<Route author="auto-bot-ty" example="/lfsyd/tag/17" path="/lfsyd/tag/:tagId" :paramsDesc="['订阅分区类型']" radar="1" rssbud="1">

| 炉石传说 | 万智牌 | 游戏王 | 昆特牌 | 影之诗 | 符文之地传奇 | 阴阳师百闻牌 |
| :------: | :----: | :----: | :----: | :----: | :----------: | :----------: |
Expand Down
5 changes: 0 additions & 5 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,6 @@ router.get('/nytimes/:lang?', lazyloadRouteHandler('./routes/nytimes/index'));
router.get('/3dm/:name/:type', lazyloadRouteHandler('./routes/3dm/game'));
router.get('/3dm/news', lazyloadRouteHandler('./routes/3dm/news_center'));

// 旅法师营地
router.get('/lfsyd/:typecode', lazyloadRouteHandler('./routes/lfsyd/index'));
router.get('/lfsyd/user/:id', lazyloadRouteHandler('./routes/lfsyd/user'));
router.get('/lfsyd/tag/:tag', lazyloadRouteHandler('./routes/lfsyd/tag'));

// 喜马拉雅
router.get('/ximalaya/album/:id/:all?', lazyloadRouteHandler('./routes/ximalaya/album'));
router.get('/ximalaya/album/:id/:all/:shownote?', lazyloadRouteHandler('./routes/ximalaya/album'));
Expand Down
50 changes: 0 additions & 50 deletions lib/routes/lfsyd/index.js

This file was deleted.

42 changes: 42 additions & 0 deletions lib/v2/lfsyd/home.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
7 changes: 7 additions & 0 deletions lib/v2/lfsyd/maintainer.js
Original file line number Diff line number Diff line change
@@ -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'],
};
29 changes: 29 additions & 0 deletions lib/v2/lfsyd/old_home.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
39 changes: 39 additions & 0 deletions lib/v2/lfsyd/radar.js
Original file line number Diff line number Diff line change
@@ -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',
},
],
},
};
6 changes: 6 additions & 0 deletions lib/v2/lfsyd/router.js
Original file line number Diff line number Diff line change
@@ -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'));
};
14 changes: 7 additions & 7 deletions lib/routes/lfsyd/tag.js → lib/v2/lfsyd/tag.js
Original file line number Diff line number Diff line change
@@ -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: '万智牌',
Expand Down Expand Up @@ -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) => ({
Expand All @@ -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,
};
};
1 change: 1 addition & 0 deletions lib/v2/lfsyd/templates/card.art
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href = "{{ url }}"></a>
14 changes: 7 additions & 7 deletions lib/routes/lfsyd/user.js → lib/v2/lfsyd/user.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,25 +24,25 @@ 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}`,
guid: item.event_data.title,
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,
};
};
Loading