From b0655082db948e2e1305512d697a6192d700574e Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 22 Oct 2021 10:52:21 +0200 Subject: [PATCH] Fix transmission and flaresolverr --- pynyaata/__init__.py | 13 ++++++++----- pynyaata/connectors/core.py | 12 ++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 9065fad..02c6e50 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -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) diff --git a/pynyaata/connectors/core.py b/pynyaata/connectors/core.py index 9f2899e..f6f1217 100644 --- a/pynyaata/connectors/core.py +++ b/pynyaata/connectors/core.py @@ -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: