Skip to content

Commit

Permalink
feat(route): 轻之国度 文章更新阅读 DIYgod#11848 (DIYgod#13938)
Browse files Browse the repository at this point in the history
* add router 关于bilibili票务

* bilibili票务基础模板

* add bilibili会员购票务 maintainer

* add cookie

* doc文档,radar

* add 补充内容

* 修改doc条目顺序,优化代码

* fix:修复doc文旦错误,移除作者备注

* fix: delete radar.js中的多余文字

* fix: 修复错误

* 开坑,轻之国度。

* 轻之国度,主体完成

* fix: router.js

* 添加文章正文内容

* 文档补全

* cookie可从环境变量赋值

* fix:补充说明

* fix:补充说明

* fix:puppeteer浏览器没有关闭的问题

* fix: 作者名字写错了

* fix: delete tpye in route,modify case

* fix: puppeteer change to got

* fix:remove collctions and puppeteer

* fix: add cookie doc

* fix: website can not run beacuse '
  • Loading branch information
nightmare-mio authored Dec 10, 2023
1 parent 7d96b03 commit 5774a57
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ const calculateValue = () => {
lastfm: {
api_key: envs.LASTFM_API_KEY,
},
lightnovel: {
cookie: envs.SECURITY_KEY,
},
manhuagui: {
cookie: envs.MHGUI_COOKIE,
},
Expand Down
62 changes: 62 additions & 0 deletions lib/v2/lightnovel/lightNovel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { parseDate } = require('@/utils/parse-date');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const config = require('@/config').value;

module.exports = async (ctx) => {
const baseUrl = 'https://www.lightnovel.us';
const { type, keywords, security_key = config.lightnovel.cookie } = ctx.params;
const { data: response } = await got({
method: 'POST',
url: `${baseUrl}/proxy/api/search/search-result`,
headers: {
// 此处是为什么
'User-Agent': config.trueUA,
},
json: {
is_encrypted: 0,
platform: 'pc',
client: 'web',
sign: '',
gz: 0,
d: {
q: keywords,
type: 0,
page: 1,
security_key,
},
},
});
const list = response.data.articles
.map((item) => ({
title: item.title,
link: `${baseUrl}/cn/detail/${item.aid}`,
pubDate: parseDate(item.time),
author: item.author,
}))
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 5);

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got({
method: 'GET',
url: item.link,
headers: {
'User-Agent': config.trueUA,
},
});

const $ = cheerio.load(response);
item.description = $('#article-main-contents').html();
return item;
})
)
);

ctx.state.data = {
title: `轻之国度-追踪${keywords}更新-${type} `,
link: baseUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/lightnovel/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:keywords/:security_key?': ['nightmare-mio'],
};
13 changes: 13 additions & 0 deletions lib/v2/lightnovel/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'lightNovel.us': {
_name: '轻之国度',
'.': [
{
title: '文章更新阅读',
docs: 'https://docs.rsshub.app/routes/anime#qing-zhi-guo-du',
source: '/',
target: '/lightnovel/:keywords/:security_key',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/lightnovel/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:keywords/:security_key?', require('./lightNovel'));
};
5 changes: 5 additions & 0 deletions website/docs/install/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ Warning: Two Factor Authentication is **not** supported.

- `LASTFM_API_KEY`: Last.fm API Key


### LightNovel.us

- `SECURITY_KEY`: security_key in the token,please remove %22,example `{%22security_key%22:%223cXXXX%22}`,only need 3cXXXX

### Email

- `EMAIL_CONFIG_{email}`: Mail setting, replace `{email}` with the email account, replace `@` and `.` in email account with `_`, e.g. `EMAIL_CONFIG_xxx_gmail_com`. The value is in the format of `password=password&host=server&port=port`, eg:
Expand Down
6 changes: 6 additions & 0 deletions website/docs/routes/anime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,12 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv

<Route author="junfengP" path="/manxiaosi/book/:id" example="/manxiaosi/book/90" paramsDesc={['漫画id,漫画主页的地址栏中']} radar="1"/>

## 轻之国度 {#qing-zhi-guo-du}

### 文章更新阅读 {#wen-zhang-geng-xing-yue-du}

<Route author="nightmare-mio" path="/lightnovel/:keywords/:security_key" example="/lightnovel/歡迎來到實力至上主義的教室/3cfc2dc63f3575ee42e12823188ad1b5:1709125:0" paramsDesc={['关键字,可以模糊匹配,但最好精确匹配。默认为文章类型','cookie,由于文章有防爬,所以必须携带cookie请求。route中的cookie优先级高于环境变量cookie,取token中的security_key值']} radar="1"/>

## 三界异次元 {#san-jie-yi-ci-yuan}

### 三界异次元 {#san-jie-yi-ci-yuan-san-jie-yi-ci-yuan}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ RSSHub 支持使用访问密钥 / 码,允许清单和拒绝清单三种方式

- `LASTFM_API_KEY`: Last.fm API Key

### LightNovel.us

- `SECURITY_KEY`: 在token中security_key的值,请去除%22,例如`{%22security_key%22:%223cXXXX%22}`,只需要3cXXXX部分

### Mastodon

用户时间线路由:访问 `https://mastodon.example/settings/applications` 申请(替换掉 `mastodon.example`)。需要 `read:search` 权限
Expand Down

0 comments on commit 5774a57

Please sign in to comment.