From f187ff99fa54eba539948054c4f184bd1dc2d083 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Mon, 11 Jan 2021 12:19:47 +0800 Subject: [PATCH] =?UTF-8?q?[Instagram]=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8A=9B=E5=87=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/install/README.md | 1 + docs/install/README.md | 1 + lib/routes/instagram/index.js | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/en/install/README.md b/docs/en/install/README.md index b61260062..4b97f5e1b 100644 --- a/docs/en/install/README.md +++ b/docs/en/install/README.md @@ -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. diff --git a/docs/install/README.md b/docs/install/README.md index a8c59fa91..b2df770d4 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -603,6 +603,7 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 - `IG_USERNAME`: Instagram 用户名。 - `IG_PASSWORD`: Instagram 密码。 + - `IG_PROXY`: Instagram 代理URL。 注意,暂不支持两步验证。 diff --git a/lib/routes/instagram/index.js b/lib/routes/instagram/index.js index 4aafe4a71..504a1f611 100644 --- a/lib/routes/instagram/index.js +++ b/lib/routes/instagram/index.js @@ -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; } }