From 1a836d914bbea991276fcfe52a3d484c999c5aa1 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Thu, 12 Sep 2019 13:30:06 +0200 Subject: [PATCH] Preroll-nope 401, 402 Closes #89 --- lib/manager/preroller.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/manager/preroller.ts b/lib/manager/preroller.ts index 9840da4..6e3b252 100644 --- a/lib/manager/preroller.ts +++ b/lib/manager/preroller.ts @@ -13,6 +13,17 @@ const PREROLL_HEURISTICS = /dl|attach|download|name|file|get|retr|^n$|\.(php|asp const PREROLL_HOSTS = /4cdn|chan/; const PREROLL_TIMEOUT = 10000; const PREROLL_NOPE = new Set(); + +/* eslint-disable no-magic-numbers */ +const NOPE_STATUSES = Object.freeze(new Set([ + 400, + 401, + 402, + 405, + 416, +])); +/* eslint-enable no-magic-numbers */ + const PREROLL_SEARCHEXTS = Object.freeze(new Set([ "php", "asp", @@ -207,7 +218,7 @@ export class Preroller { else if (status === 402 || status === 407) { rv.error = "SERVER_UNAUTHORIZED"; } - else if (status === 400 || status === 405 || status === 416) { + else if (NOPE_STATUSES.has(status)) { PREROLL_NOPE.add(this.download.uURL.host); if (PREROLL_NOPE.size > 1000) { PREROLL_NOPE.delete(PREROLL_NOPE.keys().next().value);