From 56ecddedcbf665f3c59144dc0ae181e73ea975aa Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 7 Dec 2021 11:17:01 +0100 Subject: [PATCH] Cleaning more --- .env.dist | 1 - pynyaata/__init__.py | 14 +++++++------- pynyaata/config.py | 2 -- pynyaata/connectors/__init__.py | 9 +++------ pynyaata/connectors/core.py | 6 +++--- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.env.dist b/.env.dist index d11b93a..f98f4e4 100644 --- a/.env.dist +++ b/.env.dist @@ -12,4 +12,3 @@ REQUESTS_TIMEOUT=5 CACHE_TIMEOUT=3600 MYSQL_ROOT_PASSWORD=root BLACKLIST_WORDS=Chris44,Vol.,[zza],.ssa,.ass,Ref:rain -CAPTCHA_SOLVER=hcaptcha-solver diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index d661a4e..52f345b 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -2,13 +2,10 @@ from asyncio import get_event_loop, set_event_loop, SelectorEventLoop from functools import wraps from operator import attrgetter, itemgetter -import requests -from flask import redirect, render_template, request, url_for, abort, json -from requests import RequestException +from flask import redirect, render_template, request, url_for, abort from . import utils -from .config import app, auth, logger, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG, \ - CLOUDPROXY_ENDPOINT, TRANSMISSION_ENABLED +from .config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG, TRANSMISSION_ENABLED from .connectors import get_instance, run_all, Nyaa from .connectors.core import ConnectorLang, ConnectorReturn from .forms import SearchForm, DeleteForm, EditForm, FolderDeleteForm, FolderEditForm @@ -120,7 +117,8 @@ def list_animes(url_filters='nyaa,yggtorrent'): else: filters = filters | AnimeLink.link.contains(to_filter) - titles = db.session.query(AnimeTitle, AnimeLink).join(AnimeLink).filter(filters).order_by(AnimeTitle.name).all() + titles = db.session.query(AnimeTitle, AnimeLink).join( + AnimeLink).filter(filters).order_by(AnimeTitle.name).all() results = {} for title, link in titles: @@ -240,7 +238,9 @@ def admin_edit(link_id=None): # Title title = AnimeTitle.query.filter_by(id=link.title_id).first() - title = title if title else AnimeTitle.query.filter_by(name=form.name.data).first() + title = title if title else AnimeTitle.query.filter_by( + name=form.name.data + ).first() title = title if title else AnimeTitle() title.folder_id = form.folder.data title.name = form.name.data diff --git a/pynyaata/config.py b/pynyaata/config.py index aa1eec6..959a724 100644 --- a/pynyaata/config.py +++ b/pynyaata/config.py @@ -3,7 +3,6 @@ from os import environ, urandom from flask import Flask from flask.cli import load_dotenv -from flask_apscheduler import APScheduler from flask_httpauth import HTTPBasicAuth from flask_sqlalchemy import SQLAlchemy from redis import Redis @@ -18,7 +17,6 @@ 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 [] -CLOUDPROXY_ENDPOINT = environ.get('CLOUDPROXY_ENDPOINT') MYSQL_ENABLED = False REDIS_ENABLED = False TRANSMISSION_ENABLED = False diff --git a/pynyaata/connectors/__init__.py b/pynyaata/connectors/__init__.py index 71caefe..ce94578 100644 --- a/pynyaata/connectors/__init__.py +++ b/pynyaata/connectors/__init__.py @@ -4,16 +4,13 @@ from .animeultime import AnimeUltime from .core import Other from .nyaa import Nyaa from .yggtorrent import YggTorrent, YggAnimation -from ..config import CLOUDPROXY_ENDPOINT async def run_all(*args, **kwargs): coroutines = [Nyaa(*args, **kwargs).run(), - AnimeUltime(*args, **kwargs).run()] - - if CLOUDPROXY_ENDPOINT: - coroutines.extend([YggTorrent(*args, **kwargs).run(), - YggAnimation(*args, **kwargs).run()]) + AnimeUltime(*args, **kwargs).run(), + YggTorrent(*args, **kwargs).run(), + YggAnimation(*args, **kwargs).run()] return list(await gather(*coroutines)) diff --git a/pynyaata/connectors/core.py b/pynyaata/connectors/core.py index e69bba6..193047a 100644 --- a/pynyaata/connectors/core.py +++ b/pynyaata/connectors/core.py @@ -2,13 +2,12 @@ from abc import ABC, abstractmethod from enum import Enum from functools import wraps from json import dumps, loads -from urllib.parse import urlencode import requests from requests import RequestException from redis.exceptions import RedisError -from ..config import CACHE_TIMEOUT, REQUESTS_TIMEOUT, CLOUDPROXY_ENDPOINT, logger, REDIS_ENABLED +from ..config import CACHE_TIMEOUT, REQUESTS_TIMEOUT, logger, REDIS_ENABLED if REDIS_ENABLED: from ..config import cache @@ -80,7 +79,8 @@ def curl_content(url, params=None, ajax=False, debug=True): instance = get_instance(url) if ajax: - headers = {'User-Agent': 'YggRobot', 'X-Requested-With': 'XMLHttpRequest'} + headers = {'User-Agent': 'YggRobot', + 'X-Requested-With': 'XMLHttpRequest'} else: headers = {'User-Agent': 'YggRobot'}