diff --git a/src/lib/collectors.js b/src/lib/collectors.js index 67e74e1..1efd267 100644 --- a/src/lib/collectors.js +++ b/src/lib/collectors.js @@ -41,6 +41,7 @@ async function fetchUser(username, isRSS) { function fetchUserFromHTML(username) { return userRequestCache.getOrFetch("user/"+username, false, true, () => { return switcher.request("user_html", `https://www.instagram.com/${username}/`, async res => { + if (res.status === 301) throw constants.symbols.ENDPOINT_OVERRIDDEN if (res.status === 302) throw constants.symbols.INSTAGRAM_DEMANDS_LOGIN if (res.status === 429) throw constants.symbols.RATE_LIMITED return res diff --git a/src/lib/constants.js b/src/lib/constants.js index 0dafec3..f02f9fe 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -62,7 +62,8 @@ let constants = { NOT_FOUND: Symbol("NOT_FOUND"), NO_SHARED_DATA: Symbol("NO_SHARED_DATA"), INSTAGRAM_DEMANDS_LOGIN: Symbol("INSTAGRAM_DEMANDS_LOGIN"), - RATE_LIMITED: Symbol("RATE_LIMITED") + RATE_LIMITED: Symbol("RATE_LIMITED"), + ENDPOINT_OVERRIDDEN: Symbol("ENDPOINT_OVERRIDDEN") }, database_version: 1 diff --git a/src/site/api/feed.js b/src/site/api/feed.js index 76a5d2b..e5a2e34 100644 --- a/src/site/api/feed.js +++ b/src/site/api/feed.js @@ -15,7 +15,7 @@ module.exports = [ content: xml } }).catch(error => { - if (error === constants.symbols.NOT_FOUND) { + if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) { return render(404, "pug/friendlyerror.pug", { statusCode: 404, title: "Not found", diff --git a/src/site/api/routes.js b/src/site/api/routes.js index 67a324a..85daf66 100644 --- a/src/site/api/routes.js +++ b/src/site/api/routes.js @@ -60,7 +60,7 @@ module.exports = [ } return render(200, "pug/user.pug", {url, user, constants}) }).catch(error => { - if (error === constants.symbols.NOT_FOUND) { + if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) { return render(404, "pug/friendlyerror.pug", { statusCode: 404, title: "Not found", @@ -100,7 +100,7 @@ module.exports = [ } } }).catch(error => { - if (error === constants.symbols.NOT_FOUND) { + if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) { return render(404, "pug/friendlyerror.pug", { statusCode: 404, title: "Not found",