From d3635f7175cb3ca9e65137fd8ff0158fbe6c0a3e Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 21 Feb 2020 17:11:07 +0100 Subject: [PATCH] Blacklist is now dynamic --- config.py | 1 + connectors.py | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index b22b990..7d8c35f 100644 --- a/config.py +++ b/config.py @@ -21,6 +21,7 @@ ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin') ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD', 'secret') APP_PORT = environ.get('FLASK_PORT', 5000) CACHE_TIMEOUT = environ.get('CACHE_TIMEOUT', 60 * 60) +BLACKLIST_WORDS = environ.get('BLACKLIST_WORDS', '').split(',') app = Flask(__name__) app.name = 'PyNyaaTa' diff --git a/connectors.py b/connectors.py index f3df991..264a75f 100644 --- a/connectors.py +++ b/connectors.py @@ -12,7 +12,7 @@ import requests from bs4 import BeautifulSoup from requests import ReadTimeout -from config import IS_DEBUG, CACHE_TIMEOUT +from config import IS_DEBUG, CACHE_TIMEOUT, BLACKLIST_WORDS from models import AnimeLink @@ -79,8 +79,6 @@ ConnectorCache = Cache() class Connector(ABC): - blacklist_words = ['Chris44', 'Vol.', '[zza]'] - @property @abstractmethod def color(self): @@ -248,7 +246,7 @@ class Nyaa(Connector): url = urls[0] has_comment = False - if any(word in url.string for word in self.blacklist_words): + if any(word in url.string for word in BLACKLIST_WORDS): continue valid_trs = valid_trs + 1 @@ -315,7 +313,7 @@ class Pantsu(Connector): url = tds[1].a url_safe = ''.join(url.strings) - if any(word in url_safe for word in self.blacklist_words): + if any(word in url_safe for word in BLACKLIST_WORDS): continue valid_trs = valid_trs + 1 @@ -401,7 +399,7 @@ class YggTorrent(Connector): if check_downloads or check_seeds: url = tds[1].a - if any(word in url.string for word in self.blacklist_words): + if any(word in url.string for word in BLACKLIST_WORDS): continue valid_trs = valid_trs + 1