Fix no result when no blacklist_words
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2020-04-27 20:47:54 +02:00
parent d7b0d5eba2
commit 7f07fe25e0
5 changed files with 12 additions and 11 deletions

View File

@ -13,7 +13,7 @@ ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin')
ADMIN_PASSWORD = generate_password_hash(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(',')
BLACKLIST_WORDS = environ.get('BLACKLIST_WORDS', '').split(',') if environ.get('BLACKLIST_WORDS', '') else []
MYSQL_ENABLED = False
app = Flask(__name__)

View File

@ -1,8 +1,7 @@
from bs4 import BeautifulSoup
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
from ..config import BLACKLIST_WORDS
from ..utils import parse_date, link_exist_in_db
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
class Nyaa(ConnectorCore):
@ -52,7 +51,7 @@ class Nyaa(ConnectorCore):
url_safe = url.get_text()
if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS):
if check_blacklist_words(url_safe):
continue
valid_trs = valid_trs + 1

View File

@ -1,8 +1,7 @@
from bs4 import BeautifulSoup
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
from ..config import BLACKLIST_WORDS
from ..utils import parse_date, link_exist_in_db
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
class Pantsu(ConnectorCore):
@ -44,7 +43,7 @@ class Pantsu(ConnectorCore):
url = tds[1].a
url_safe = url.get_text()
if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS):
if check_blacklist_words(url_safe):
continue
valid_trs = valid_trs + 1

View File

@ -5,8 +5,7 @@ from urllib.parse import quote
from bs4 import BeautifulSoup
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
from ..config import BLACKLIST_WORDS
from ..utils import parse_date, link_exist_in_db
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
class YggTorrent(ConnectorCore):
@ -52,7 +51,7 @@ class YggTorrent(ConnectorCore):
url = tds[1].a
url_safe = url.get_text()
if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS):
if check_blacklist_words(url_safe):
continue
valid_trs = valid_trs + 1

View File

@ -3,7 +3,7 @@ from datetime import datetime
from dateparser import parse
from . import MYSQL_ENABLED
from .config import MYSQL_ENABLED, BLACKLIST_WORDS
def link_exist_in_db(href):
@ -41,3 +41,7 @@ def clean_model(obj):
except AttributeError:
pass
return obj
def check_blacklist_words(url):
return any(word.lower() in url.lower() for word in BLACKLIST_WORDS)