Merge branch 'master' of ssh://patema.crystalyx.net:2222/Xefir/PyNyaaTa
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Michel Roux 2021-10-23 19:15:45 +00:00
commit a037ce6c18
2 changed files with 14 additions and 11 deletions

View File

@ -8,7 +8,7 @@ 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, scheduler, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG, \
CLOUDPROXY_ENDPOINT, TRANSMISSION_ENABLED, transmission 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
from .forms import SearchForm, DeleteForm, EditForm, FolderDeleteForm, FolderEditForm from .forms import SearchForm, DeleteForm, EditForm, FolderDeleteForm, FolderEditForm
@ -17,6 +17,9 @@ if MYSQL_ENABLED:
from .config import db from .config import db
from .models import AnimeFolder, AnimeTitle, AnimeLink from .models import AnimeFolder, AnimeTitle, AnimeLink
if TRANSMISSION_ENABLED:
from .config import transmission
def mysql_required(f): def mysql_required(f):
@wraps(f) @wraps(f)
@ -281,17 +284,17 @@ def admin_edit(link_id=None):
def flaredestroyy(): def flaredestroyy():
if CLOUDPROXY_ENDPOINT: if CLOUDPROXY_ENDPOINT:
try: try:
json_session = requests.post(CLOUDPROXY_ENDPOINT, data=json.dumps({ json_session = requests.post(CLOUDPROXY_ENDPOINT, json={
'cmd': 'sessions.list' 'cmd': 'sessions.list'
})) })
response = json.loads(json_session.text) response = json.loads(json_session.text)
sessions = response['sessions'] sessions = response['sessions']
for session in sessions: for session in sessions:
requests.post(CLOUDPROXY_ENDPOINT, data=json.dumps({ requests.post(CLOUDPROXY_ENDPOINT, json={
'cmd': 'sessions.destroy', 'cmd': 'sessions.destroy',
'session': session 'session': session
})) })
logger.info('Destroyed %s' % session) logger.info('Destroyed %s' % session)
except RequestException as e: except RequestException as e:
logger.exception(e) logger.exception(e)

View File

@ -105,9 +105,9 @@ def curl_content(url, params=None, ajax=False, debug=True):
elif CLOUDPROXY_ENDPOINT: elif CLOUDPROXY_ENDPOINT:
global cloudproxy_session global cloudproxy_session
if not cloudproxy_session: if not cloudproxy_session:
json_session = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, data=dumps({ json_session = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={
'cmd': 'sessions.create' 'cmd': 'sessions.create'
})) })
response_session = loads(json_session.text) response_session = loads(json_session.text)
cloudproxy_session = response_session['session'] cloudproxy_session = response_session['session']
@ -116,12 +116,12 @@ def curl_content(url, params=None, ajax=False, debug=True):
else: else:
headers['Content-Type'] = 'application/json' headers['Content-Type'] = 'application/json'
json_response = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, data=dumps({ json_response = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={
'cmd': 'request.%s' % method, 'cmd': 'request.%s' % method,
'url': url, 'url': url,
'session': cloudproxy_session, 'session': cloudproxy_session,
'postData': '%s' % urlencode(params) if (method == 'post') else '' 'postData': '%s' % urlencode(params) if (method == 'post') else ''
})) })
http_code = json_response.status_code http_code = json_response.status_code
response = loads(json_response.text) response = loads(json_response.text)
@ -129,10 +129,10 @@ def curl_content(url, params=None, ajax=False, debug=True):
output = response['solution']['response'] output = response['solution']['response']
if http_code == 500: if http_code == 500:
requests.post(CLOUDPROXY_ENDPOINT, headers=headers, data=dumps({ requests.post(CLOUDPROXY_ENDPOINT, headers=headers, json={
'cmd': 'sessions.destroy', 'cmd': 'sessions.destroy',
'session': cloudproxy_session, 'session': cloudproxy_session,
})) })
cloudproxy_session = None cloudproxy_session = None
except RequestException as e: except RequestException as e:
if debug: if debug: