From 5774a576a905bb52de52ce594d569d6b24b4ffb1 Mon Sep 17 00:00:00 2001 From: nightmare-mio <52735303+nightmare-mio@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:56:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E8=BD=BB=E4=B9=8B=E5=9B=BD?= =?UTF-8?q?=E5=BA=A6=20=E6=96=87=E7=AB=A0=E6=9B=B4=E6=96=B0=E9=98=85?= =?UTF-8?q?=E8=AF=BB=20#11848=20(#13938)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 ' --- lib/config.js | 3 + lib/v2/lightnovel/lightNovel.js | 62 +++++++++++++++++++ lib/v2/lightnovel/maintainer.js | 3 + lib/v2/lightnovel/radar.js | 13 ++++ lib/v2/lightnovel/router.js | 3 + website/docs/install/config.md | 5 ++ website/docs/routes/anime.mdx | 6 ++ .../current/install/config.md | 4 ++ 8 files changed, 99 insertions(+) create mode 100644 lib/v2/lightnovel/lightNovel.js create mode 100644 lib/v2/lightnovel/maintainer.js create mode 100644 lib/v2/lightnovel/radar.js create mode 100644 lib/v2/lightnovel/router.js diff --git a/lib/config.js b/lib/config.js index b234865fd..e2cdcf313 100644 --- a/lib/config.js +++ b/lib/config.js @@ -219,6 +219,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 000000000..4df817ca4 --- /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 000000000..d595d38ac --- /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 000000000..8bfc52d88 --- /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 000000000..f77e80fa4 --- /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 bc6531cb4..f82dd90ee 100644 --- a/website/docs/install/config.md +++ b/website/docs/install/config.md @@ -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: diff --git a/website/docs/routes/anime.mdx b/website/docs/routes/anime.mdx index 410b516e7..555ac30d7 100644 --- a/website/docs/routes/anime.mdx +++ b/website/docs/routes/anime.mdx @@ -837,6 +837,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 a7e19f016..01cb21a4f 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 @@ -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` 权限