diff --git a/lib/config.js b/lib/config.js index eac901a4246..db0d679a599 100644 --- a/lib/config.js +++ b/lib/config.js @@ -218,6 +218,9 @@ const calculateValue = () => { lastfm: { api_key: envs.LASTFM_API_KEY, }, + lightnovel: { + cookie: envs.SECURITY_KEY, + }, manhuagui: { cookie: envs.MHGUI_COOKIE, }, diff --git a/lib/v2/lightnovel/lightNovel.js b/lib/v2/lightnovel/lightNovel.js new file mode 100644 index 00000000000..4df817ca4e1 --- /dev/null +++ b/lib/v2/lightnovel/lightNovel.js @@ -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, + }; +}; diff --git a/lib/v2/lightnovel/maintainer.js b/lib/v2/lightnovel/maintainer.js new file mode 100644 index 00000000000..d595d38ac2a --- /dev/null +++ b/lib/v2/lightnovel/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:keywords/:security_key?': ['nightmare-mio'], +}; diff --git a/lib/v2/lightnovel/radar.js b/lib/v2/lightnovel/radar.js new file mode 100644 index 00000000000..8bfc52d88d3 --- /dev/null +++ b/lib/v2/lightnovel/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/lightnovel/router.js b/lib/v2/lightnovel/router.js new file mode 100644 index 00000000000..f77e80fa4d4 --- /dev/null +++ b/lib/v2/lightnovel/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:keywords/:security_key?', require('./lightNovel')); +}; diff --git a/website/docs/install/config.md b/website/docs/install/config.md index 8202d43c865..5724dc6266a 100644 --- a/website/docs/install/config.md +++ b/website/docs/install/config.md @@ -361,6 +361,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: diff --git a/website/docs/routes/anime.mdx b/website/docs/routes/anime.mdx index 9f8474f7f9e..50c6cb538d6 100644 --- a/website/docs/routes/anime.mdx +++ b/website/docs/routes/anime.mdx @@ -834,6 +834,12 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv +## 轻之国度 {#qing-zhi-guo-du} + +### 文章更新阅读 {#wen-zhang-geng-xing-yue-du} + + + ## 三界异次元 {#san-jie-yi-ci-yuan} ### 三界异次元 {#san-jie-yi-ci-yuan-san-jie-yi-ci-yuan} diff --git a/website/i18n/zh/docusaurus-plugin-content-docs/current/install/config.md b/website/i18n/zh/docusaurus-plugin-content-docs/current/install/config.md index dba54a0abfb..114b247c4c9 100644 --- a/website/i18n/zh/docusaurus-plugin-content-docs/current/install/config.md +++ b/website/i18n/zh/docusaurus-plugin-content-docs/current/install/config.md @@ -356,6 +356,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` 权限