diff --git a/.env.dist b/.env.dist index 52fbaee..d11b93a 100644 --- a/.env.dist +++ b/.env.dist @@ -12,5 +12,4 @@ REQUESTS_TIMEOUT=5 CACHE_TIMEOUT=3600 MYSQL_ROOT_PASSWORD=root BLACKLIST_WORDS=Chris44,Vol.,[zza],.ssa,.ass,Ref:rain -CLOUDPROXY_ENDPOINT=http://flaresolverr:8191/v1 CAPTCHA_SOLVER=hcaptcha-solver diff --git a/README.md b/README.md index 91ad8ce..483f2c6 100644 --- a/README.md +++ b/README.md @@ -40,17 +40,6 @@ All is managed by environment variables. Please look into the `.env.dist` file to list all possible environment variables. You have to install MariaDB (or any MySQL server) to be able to access the admin panel. -### Bypassing CloudFlare for YggTorrent - -YggTorrent use CloudFlare to protect them to DDoS attacks. -This app will make abusive requests to their servers, and CloudFlare will try to detect if PyNyaaTa is a real human or not. *I think you have the answer to the question ...* -Over time, CloudFlare will ask you systematically to prove yourself. -To be able to see YggTorrent results, you have to have a FlareSolverr instance running. -Please refer to their [documentation](https://github.com/FlareSolverr/FlareSolverr#installation). -After that, change the `CLOUDPROXY_ENDPOINT` environment variable to refer to your CloudProxy instance. - -If you use PyNyaaTa with Docker and the `docker-compose.yml` from this repository, you don't have to do all this, it comes pre-installed. - ## Links - Project homepage: https://nyaa.crystalyx.net/ diff --git a/docker-compose.yml b/docker-compose.yml index 56e63c1..97438fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,6 @@ services: working_dir: /app depends_on: - db - - flaresolverr - redis env_file: - .env.dist @@ -31,11 +30,3 @@ services: image: redis ports: - "6379:6379" - - flaresolverr: - image: flaresolverr/flaresolverr - ports: - - "8191:8191" - env_file: - - .env.dist - - .env diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 02c6e50..d661a4e 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -7,7 +7,7 @@ from flask import redirect, render_template, request, url_for, abort, json from requests import RequestException from . import utils -from .config import app, auth, logger, scheduler, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG, \ +from .config import app, auth, logger, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG, \ CLOUDPROXY_ENDPOINT, TRANSMISSION_ENABLED from .connectors import get_instance, run_all, Nyaa from .connectors.core import ConnectorLang, ConnectorReturn @@ -280,27 +280,5 @@ def admin_edit(link_id=None): return render_template('admin/edit.html', search_form=SearchForm(), folders=folders, action_form=form) -@scheduler.task('interval', id='flaredestroyy', days=1) -def flaredestroyy(): - if CLOUDPROXY_ENDPOINT: - try: - json_session = requests.post(CLOUDPROXY_ENDPOINT, json={ - 'cmd': 'sessions.list' - }) - response = json.loads(json_session.text) - sessions = response['sessions'] - - for session in sessions: - requests.post(CLOUDPROXY_ENDPOINT, json={ - 'cmd': 'sessions.destroy', - 'session': session - }) - logger.info('Destroyed %s' % session) - except RequestException as e: - logger.exception(e) - - def run(): - scheduler.start() - flaredestroyy() app.run('0.0.0.0', APP_PORT, IS_DEBUG) diff --git a/pynyaata/config.py b/pynyaata/config.py index 7f40e9c..aa1eec6 100644 --- a/pynyaata/config.py +++ b/pynyaata/config.py @@ -29,7 +29,6 @@ app.debug = IS_DEBUG app.secret_key = urandom(24).hex() app.url_map.strict_slashes = False auth = HTTPBasicAuth() -scheduler = APScheduler(app=app) logging.basicConfig(level=(logging.DEBUG if IS_DEBUG else logging.INFO)) logger = logging.getLogger(app.name) diff --git a/pynyaata/connectors/animeultime.py b/pynyaata/connectors/animeultime.py index 9c34343..49a3913 100644 --- a/pynyaata/connectors/animeultime.py +++ b/pynyaata/connectors/animeultime.py @@ -12,7 +12,6 @@ class AnimeUltime(ConnectorCore): favicon = 'animeultime.png' base_url = 'http://www.anime-ultime.net' is_light = True - is_behind_cloudflare = False def get_full_search_url(self): from_date = '' diff --git a/pynyaata/connectors/core.py b/pynyaata/connectors/core.py index f6f1217..e69bba6 100644 --- a/pynyaata/connectors/core.py +++ b/pynyaata/connectors/core.py @@ -80,60 +80,27 @@ def curl_content(url, params=None, ajax=False, debug=True): instance = get_instance(url) if ajax: - headers = {'X-Requested-With': 'XMLHttpRequest'} + headers = {'User-Agent': 'YggRobot', 'X-Requested-With': 'XMLHttpRequest'} else: - headers = {} + headers = {'User-Agent': 'YggRobot'} try: - if not instance.is_behind_cloudflare: - if method == 'post': - response = requests.post( - url, - params, - timeout=REQUESTS_TIMEOUT, - headers=headers - ) - else: - response = requests.get( - url, - timeout=REQUESTS_TIMEOUT, - headers=headers - ) + if method == 'post': + response = requests.post( + url, + params, + timeout=REQUESTS_TIMEOUT, + headers=headers + ) + else: + response = requests.get( + url, + timeout=REQUESTS_TIMEOUT, + headers=headers + ) - output = response.text - http_code = response.status_code - elif CLOUDPROXY_ENDPOINT: - global cloudproxy_session - if not cloudproxy_session: - json_session = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={ - 'cmd': 'sessions.create' - }) - response_session = loads(json_session.text) - cloudproxy_session = response_session['session'] - - if method == 'post': - headers['Content-Type'] = 'application/x-www-form-urlencoded' - else: - headers['Content-Type'] = 'application/json' - - json_response = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={ - 'cmd': 'request.%s' % method, - 'url': url, - 'session': cloudproxy_session, - 'postData': '%s' % urlencode(params) if (method == 'post') else '' - }) - - http_code = json_response.status_code - response = loads(json_response.text) - if 'solution' in response: - output = response['solution']['response'] - - if http_code == 500: - requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={ - 'cmd': 'sessions.destroy', - 'session': cloudproxy_session, - }) - cloudproxy_session = None + output = response.text + http_code = response.status_code except RequestException as e: if debug: logger.exception(e) @@ -167,11 +134,6 @@ class ConnectorCore(ABC): def is_light(self): pass - @property - @abstractmethod - def is_behind_cloudflare(self): - pass - def __init__(self, query, page=1, return_type=ConnectorReturn.SEARCH): self.query = query self.data = [] @@ -211,7 +173,6 @@ class Other(ConnectorCore): favicon = 'blank.png' base_url = '' is_light = True - is_behind_cloudflare = False def get_full_search_url(self): pass diff --git a/pynyaata/connectors/nyaa.py b/pynyaata/connectors/nyaa.py index 5e37d43..b118b98 100644 --- a/pynyaata/connectors/nyaa.py +++ b/pynyaata/connectors/nyaa.py @@ -10,7 +10,6 @@ class Nyaa(ConnectorCore): favicon = 'nyaa.png' base_url = 'https://nyaa.si' is_light = False - is_behind_cloudflare = False def get_full_search_url(self): sort_type = 'size' diff --git a/pynyaata/connectors/yggtorrent.py b/pynyaata/connectors/yggtorrent.py index 10b8037..ad3f043 100644 --- a/pynyaata/connectors/yggtorrent.py +++ b/pynyaata/connectors/yggtorrent.py @@ -15,7 +15,6 @@ class YggTorrent(ConnectorCore): base_url = 'https://www3.yggtorrent.nz' is_light = False category = 2179 - is_behind_cloudflare = False def get_full_search_url(self): sort_type = 'size' diff --git a/requirements.txt b/requirements.txt index c071613..84cf557 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ Flask==2.0.2 -Flask-APScheduler==1.12.2 Flask-SQLAlchemy==2.5.1 Flask-HTTPAuth==4.5.0 Flask-WTF==1.0.0