Fix no result when no blacklist_words
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d7b0d5eba2
commit
7f07fe25e0
@ -13,7 +13,7 @@ ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin')
|
|||||||
ADMIN_PASSWORD = generate_password_hash(environ.get('ADMIN_PASSWORD', 'secret'))
|
ADMIN_PASSWORD = generate_password_hash(environ.get('ADMIN_PASSWORD', 'secret'))
|
||||||
APP_PORT = environ.get('FLASK_PORT', 5000)
|
APP_PORT = environ.get('FLASK_PORT', 5000)
|
||||||
CACHE_TIMEOUT = environ.get('CACHE_TIMEOUT', 60 * 60)
|
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
|
MYSQL_ENABLED = False
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
||||||
from ..config import BLACKLIST_WORDS
|
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
|
||||||
from ..utils import parse_date, link_exist_in_db
|
|
||||||
|
|
||||||
|
|
||||||
class Nyaa(ConnectorCore):
|
class Nyaa(ConnectorCore):
|
||||||
@ -52,7 +51,7 @@ class Nyaa(ConnectorCore):
|
|||||||
|
|
||||||
url_safe = url.get_text()
|
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
|
continue
|
||||||
|
|
||||||
valid_trs = valid_trs + 1
|
valid_trs = valid_trs + 1
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
||||||
from ..config import BLACKLIST_WORDS
|
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
|
||||||
from ..utils import parse_date, link_exist_in_db
|
|
||||||
|
|
||||||
|
|
||||||
class Pantsu(ConnectorCore):
|
class Pantsu(ConnectorCore):
|
||||||
@ -44,7 +43,7 @@ class Pantsu(ConnectorCore):
|
|||||||
url = tds[1].a
|
url = tds[1].a
|
||||||
url_safe = url.get_text()
|
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
|
continue
|
||||||
|
|
||||||
valid_trs = valid_trs + 1
|
valid_trs = valid_trs + 1
|
||||||
|
@ -5,8 +5,7 @@ from urllib.parse import quote
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
from .core import ConnectorCore, ConnectorReturn, ConnectorCache, curl_content
|
||||||
from ..config import BLACKLIST_WORDS
|
from ..utils import parse_date, link_exist_in_db, check_blacklist_words
|
||||||
from ..utils import parse_date, link_exist_in_db
|
|
||||||
|
|
||||||
|
|
||||||
class YggTorrent(ConnectorCore):
|
class YggTorrent(ConnectorCore):
|
||||||
@ -52,7 +51,7 @@ class YggTorrent(ConnectorCore):
|
|||||||
url = tds[1].a
|
url = tds[1].a
|
||||||
url_safe = url.get_text()
|
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
|
continue
|
||||||
|
|
||||||
valid_trs = valid_trs + 1
|
valid_trs = valid_trs + 1
|
||||||
|
@ -3,7 +3,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
from dateparser import parse
|
from dateparser import parse
|
||||||
|
|
||||||
from . import MYSQL_ENABLED
|
from .config import MYSQL_ENABLED, BLACKLIST_WORDS
|
||||||
|
|
||||||
|
|
||||||
def link_exist_in_db(href):
|
def link_exist_in_db(href):
|
||||||
@ -41,3 +41,7 @@ def clean_model(obj):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def check_blacklist_words(url):
|
||||||
|
return any(word.lower() in url.lower() for word in BLACKLIST_WORDS)
|
||||||
|
Reference in New Issue
Block a user