fix: (semi-fix) login to NGA to prevent 403 error. (#5747)

This commit is contained in:
sgqy
2020-10-03 21:24:15 +01:00
committed by GitHub
parent 565ab1f889
commit b538f75ef6
6 changed files with 38 additions and 16 deletions
+12
View File
@@ -407,12 +407,24 @@ See the relation between access key/code and white/blacklisting.
### Route-specific Configurations
::: tip Notice
Configs here is incomplete.
See docs of specified route and `lib/config.js` for detail information.
:::
- pixiv: [Registration](https://accounts.pixiv.net/signup)
- `PIXIV_USERNAME`: Pixiv username
- `PIXIV_PASSWORD`: Pixiv password
- pixiv fanbox: Get paid content
- `FANBOX_SESSION_ID`: equals to `FANBOXSESSID` in site cookies.
- disqus: [API Key application](https://disqus.com/api/applications/)
- `DISQUS_API_KEY`: Disqus API
-8
View File
@@ -118,14 +118,6 @@ Only for self-hosted
## pixiv-fanbox
<RouteEn author="sgqy" example="/fanbox/otomeoto" path="/fanbox/:user?" :paramsDesc="['User name. Can be found in URL. Default is official news']"/>
::: warning Paywall
The site **fanbox** is made for paid users. To get paid content, you should host by yourself.
Settings: environment argument `FANBOX_SESSION_ID` equals to `FANBOXSESSID` in site cookies.
:::
## Telegram
+16
View File
@@ -434,12 +434,22 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
### 部分 RSS 模块配置
::: tip 提示
此处信息不完整。完整配置请参考路由对应的文档和 `lib/config.js`。
:::
- pixiv 全部路由:[注册地址](https://accounts.pixiv.net/signup)
- `PIXIV_USERNAME`: Pixiv 用户名
- `PIXIV_PASSWORD`: Pixiv 密码
- pixiv fanbox 用于获取付费内容
- `FANBOX_SESSION_ID`: 对应 cookies 中的`FANBOXSESSID`。
- disqus 全部路由:[申请地址](https://disqus.com/api/applications/)
- `DISQUS_API_KEY`: Disqus API
@@ -544,3 +554,9 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- 新榜
- `NEWRANK_COOKIE`: 登陆后的 COOKIE 值,其中 token 是必要的,其他可删除
- NGA BBS 用于获取帖子内文
- `NGA_PASSPORT_UID`: 对应 cookie 中的 `ngaPassportUid`.
- `NGA_PASSPORT_CID`: 对应 cookie 中的 `ngaPassportCid`.
-7
View File
@@ -406,13 +406,6 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
## pixiv-fanbox
<Route author="sgqy" example="/fanbox/otomeoto" path="/fanbox/:user?" :paramsDesc="['用户名, 可在用户主页 URL 中找到. 默认为官方资讯']"/>
::: warning 付费墙注意
由于 fanbox 专为付费用户设计,要查看已经付费的内容只能自建。
自建设置:环境变量`FANBOX_SESSION_ID`对应 cookies 中的`FANBOXSESSID`。
:::
## Popi 提问箱
+4
View File
@@ -156,6 +156,10 @@ const calculateValue = () => {
device_id: envs.XIAOYUZHOU_ID,
refresh_token: envs.XIAOYUZHOU_TOKEN,
},
nga: {
uid: envs.NGA_PASSPORT_UID,
cid: envs.NGA_PASSPORT_CID,
},
newrank: {
cookie: envs.NEWRANK_COOKIE,
},
+6 -1
View File
@@ -1,18 +1,23 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const config = require('@/config').value;
module.exports = async (ctx) => {
const getPageUrl = (tid, page = 1, hash = '') => `https://nga.178.com/read.php?tid=${tid}&page=${page}&rand=${Math.random() * 1000}#${hash}`;
const getPage = async (tid, pageId = 1) => {
const link = getPageUrl(tid, pageId);
const timestamp = Math.floor(Date.now() / 1000);
let cookieString = `guestJs=${timestamp};`;
if (config.nga.uid && config.nga.cid) {
cookieString = `ngaPassportUid=${config.nga.uid}; ngaPassportCid=${config.nga.cid};`;
}
const response = await got({
method: 'get',
url: link,
responseType: 'buffer',
headers: {
Cookie: `guestJs=${timestamp};`,
Cookie: cookieString,
},
});