Fix transmission and flaresolverr
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2021-10-22 10:52:21 +02:00
parent 766a91134a
commit b0655082db
2 changed files with 14 additions and 11 deletions

View File

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

View File

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