From d2d8578c1a484683de58d07a127ff7faaadbbeb5 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 19 Oct 2020 23:15:58 +0200 Subject: [PATCH] Fix YGG spam --- get404.py | 2 +- pynyaata/config.py | 6 +++--- pynyaata/connectors/yggtorrent.py | 3 +++ pynyaata/templates/search.html | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/get404.py b/get404.py index b2e0bea..2085f82 100644 --- a/get404.py +++ b/get404.py @@ -8,7 +8,7 @@ links = AnimeLink.query.all() for link in links: html = curl_content(link.link, debug=False) - if html['http_code'] != 200: + if html['http_code'] != 200 and html['http_code'] != 500: print('(%d) %s %s : %s' % (html['http_code'], link.title.name, link.season, link.link)) elif 'darkgray' in str(html['output']): print('(darkgray) %s %s : %s' % (link.title.name, link.season, link.link)) diff --git a/pynyaata/config.py b/pynyaata/config.py index 06a8607..f9340ae 100644 --- a/pynyaata/config.py +++ b/pynyaata/config.py @@ -11,9 +11,9 @@ load_dotenv() IS_DEBUG = environ.get('FLASK_ENV', 'production') == 'development' 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) -REQUESTS_TIMEOUT = environ.get('REQUESTS_TIMEOUT', 5) +APP_PORT = int(environ.get('FLASK_PORT', 5000)) +CACHE_TIMEOUT = int(environ.get('CACHE_TIMEOUT', 60 * 60)) +REQUESTS_TIMEOUT = int(environ.get('REQUESTS_TIMEOUT', 5)) BLACKLIST_WORDS = environ.get('BLACKLIST_WORDS', '').split(',') if environ.get('BLACKLIST_WORDS', '') else [] MYSQL_ENABLED = False diff --git a/pynyaata/connectors/yggtorrent.py b/pynyaata/connectors/yggtorrent.py index e727b2b..cf0667d 100644 --- a/pynyaata/connectors/yggtorrent.py +++ b/pynyaata/connectors/yggtorrent.py @@ -75,6 +75,9 @@ class YggTorrent(ConnectorCore): self.on_error = False self.is_more = valid_trs and valid_trs is not len(trs) - 1 + elif response['http_code'] == 500: + self.on_error = False + self.is_more = True class YggAnimation(YggTorrent): diff --git a/pynyaata/templates/search.html b/pynyaata/templates/search.html index d3e08db..03fd674 100644 --- a/pynyaata/templates/search.html +++ b/pynyaata/templates/search.html @@ -25,11 +25,11 @@ {% for connector in connectors %} - {% for torrent in connector.data %} - {% if not loop.index0 %} - {{ connector.title }} - {% endif %} + {% if connector.data|length > 0 or connector.is_more %} + {{ connector.title }} + {% endif %} + {% for torrent in connector.data %} {{ torrent.lang.value }}