Merge pull request #6659 from lifegpc/patch1

[Instagram]增加代理设置,修改抛出错误的方式
This commit is contained in:
NeverBehave 2021-01-10 23:28:20 -05:00 committed by GitHub
commit e997e86340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -494,6 +494,7 @@ See docs of specified route and `lib/config.js` for detail information.
- `IG_USERNAME`: Your Instagram username
- `IG_PASSWORD`: Your Instagram password
- `IG_PROXY`: Proxy URL for Instagram
Warning: Two Factor Authentication is *not* supported.

View File

@ -603,6 +603,7 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- `IG_USERNAME`: Instagram 用户名。
- `IG_PASSWORD`: Instagram 密码。
- `IG_PROXY`: Instagram 代理URL。
注意,暂不支持两步验证。

View File

@ -15,13 +15,17 @@ module.exports = async (ctx) => {
throw Error('Such feed is not supported.');
}
if (process.env.IG_PROXY) {
ig.state.proxyUrl = process.env.IG_PROXY;
}
try {
await ig.account.currentUser();
} catch (e) {
if (e instanceof IgLoginRequiredError) {
await login(ig);
} else {
throw Error('Unknown error');
throw e;
}
}