This commit is contained in:
parent
fe0f4b4545
commit
8eab694d02
@ -12,5 +12,4 @@ REQUESTS_TIMEOUT=5
|
|||||||
CACHE_TIMEOUT=3600
|
CACHE_TIMEOUT=3600
|
||||||
MYSQL_ROOT_PASSWORD=root
|
MYSQL_ROOT_PASSWORD=root
|
||||||
BLACKLIST_WORDS=Chris44,Vol.,[zza],.ssa,.ass,Ref:rain
|
BLACKLIST_WORDS=Chris44,Vol.,[zza],.ssa,.ass,Ref:rain
|
||||||
CLOUDPROXY_ENDPOINT=http://flaresolverr:8191/v1
|
|
||||||
CAPTCHA_SOLVER=hcaptcha-solver
|
CAPTCHA_SOLVER=hcaptcha-solver
|
||||||
|
11
README.md
11
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.
|
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.
|
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
|
## Links
|
||||||
|
|
||||||
- Project homepage: https://nyaa.crystalyx.net/
|
- Project homepage: https://nyaa.crystalyx.net/
|
||||||
|
@ -9,7 +9,6 @@ services:
|
|||||||
working_dir: /app
|
working_dir: /app
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- flaresolverr
|
|
||||||
- redis
|
- redis
|
||||||
env_file:
|
env_file:
|
||||||
- .env.dist
|
- .env.dist
|
||||||
@ -31,11 +30,3 @@ services:
|
|||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
|
|
||||||
flaresolverr:
|
|
||||||
image: flaresolverr/flaresolverr
|
|
||||||
ports:
|
|
||||||
- "8191:8191"
|
|
||||||
env_file:
|
|
||||||
- .env.dist
|
|
||||||
- .env
|
|
||||||
|
@ -7,7 +7,7 @@ from flask import redirect, render_template, request, url_for, abort, json
|
|||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
|
|
||||||
from . import utils
|
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
|
CLOUDPROXY_ENDPOINT, TRANSMISSION_ENABLED
|
||||||
from .connectors import get_instance, run_all, Nyaa
|
from .connectors import get_instance, run_all, Nyaa
|
||||||
from .connectors.core import ConnectorLang, ConnectorReturn
|
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)
|
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():
|
def run():
|
||||||
scheduler.start()
|
|
||||||
flaredestroyy()
|
|
||||||
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
|
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
|
||||||
|
@ -29,7 +29,6 @@ app.debug = IS_DEBUG
|
|||||||
app.secret_key = urandom(24).hex()
|
app.secret_key = urandom(24).hex()
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
auth = HTTPBasicAuth()
|
auth = HTTPBasicAuth()
|
||||||
scheduler = APScheduler(app=app)
|
|
||||||
logging.basicConfig(level=(logging.DEBUG if IS_DEBUG else logging.INFO))
|
logging.basicConfig(level=(logging.DEBUG if IS_DEBUG else logging.INFO))
|
||||||
logger = logging.getLogger(app.name)
|
logger = logging.getLogger(app.name)
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ class AnimeUltime(ConnectorCore):
|
|||||||
favicon = 'animeultime.png'
|
favicon = 'animeultime.png'
|
||||||
base_url = 'http://www.anime-ultime.net'
|
base_url = 'http://www.anime-ultime.net'
|
||||||
is_light = True
|
is_light = True
|
||||||
is_behind_cloudflare = False
|
|
||||||
|
|
||||||
def get_full_search_url(self):
|
def get_full_search_url(self):
|
||||||
from_date = ''
|
from_date = ''
|
||||||
|
@ -80,12 +80,11 @@ def curl_content(url, params=None, ajax=False, debug=True):
|
|||||||
instance = get_instance(url)
|
instance = get_instance(url)
|
||||||
|
|
||||||
if ajax:
|
if ajax:
|
||||||
headers = {'X-Requested-With': 'XMLHttpRequest'}
|
headers = {'User-Agent': 'YggRobot', 'X-Requested-With': 'XMLHttpRequest'}
|
||||||
else:
|
else:
|
||||||
headers = {}
|
headers = {'User-Agent': 'YggRobot'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not instance.is_behind_cloudflare:
|
|
||||||
if method == 'post':
|
if method == 'post':
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url,
|
url,
|
||||||
@ -102,38 +101,6 @@ def curl_content(url, params=None, ajax=False, debug=True):
|
|||||||
|
|
||||||
output = response.text
|
output = response.text
|
||||||
http_code = response.status_code
|
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
|
|
||||||
except RequestException as e:
|
except RequestException as e:
|
||||||
if debug:
|
if debug:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
@ -167,11 +134,6 @@ class ConnectorCore(ABC):
|
|||||||
def is_light(self):
|
def is_light(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
|
||||||
@abstractmethod
|
|
||||||
def is_behind_cloudflare(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self, query, page=1, return_type=ConnectorReturn.SEARCH):
|
def __init__(self, query, page=1, return_type=ConnectorReturn.SEARCH):
|
||||||
self.query = query
|
self.query = query
|
||||||
self.data = []
|
self.data = []
|
||||||
@ -211,7 +173,6 @@ class Other(ConnectorCore):
|
|||||||
favicon = 'blank.png'
|
favicon = 'blank.png'
|
||||||
base_url = ''
|
base_url = ''
|
||||||
is_light = True
|
is_light = True
|
||||||
is_behind_cloudflare = False
|
|
||||||
|
|
||||||
def get_full_search_url(self):
|
def get_full_search_url(self):
|
||||||
pass
|
pass
|
||||||
|
@ -10,7 +10,6 @@ class Nyaa(ConnectorCore):
|
|||||||
favicon = 'nyaa.png'
|
favicon = 'nyaa.png'
|
||||||
base_url = 'https://nyaa.si'
|
base_url = 'https://nyaa.si'
|
||||||
is_light = False
|
is_light = False
|
||||||
is_behind_cloudflare = False
|
|
||||||
|
|
||||||
def get_full_search_url(self):
|
def get_full_search_url(self):
|
||||||
sort_type = 'size'
|
sort_type = 'size'
|
||||||
|
@ -15,7 +15,6 @@ class YggTorrent(ConnectorCore):
|
|||||||
base_url = 'https://www3.yggtorrent.nz'
|
base_url = 'https://www3.yggtorrent.nz'
|
||||||
is_light = False
|
is_light = False
|
||||||
category = 2179
|
category = 2179
|
||||||
is_behind_cloudflare = False
|
|
||||||
|
|
||||||
def get_full_search_url(self):
|
def get_full_search_url(self):
|
||||||
sort_type = 'size'
|
sort_type = 'size'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
Flask==2.0.2
|
Flask==2.0.2
|
||||||
Flask-APScheduler==1.12.2
|
|
||||||
Flask-SQLAlchemy==2.5.1
|
Flask-SQLAlchemy==2.5.1
|
||||||
Flask-HTTPAuth==4.5.0
|
Flask-HTTPAuth==4.5.0
|
||||||
Flask-WTF==1.0.0
|
Flask-WTF==1.0.0
|
||||||
|
Reference in New Issue
Block a user