Thanks YGG for YggRobot :D
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Michel Roux 2021-12-07 11:09:45 +01:00
parent fe0f4b4545
commit 8eab694d02
10 changed files with 18 additions and 105 deletions

View File

@ -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

View File

@ -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/

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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 = ''

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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