diff --git a/components/core/Server.py b/components/core/Server.py index 7063f6dd..8ddc2c8a 100644 --- a/components/core/Server.py +++ b/components/core/Server.py @@ -68,3 +68,5 @@ def serve_ui1(): # file sending endpoints server.add_url_rule(rule='/api/file', endpoint='send_file_from_path', view_func=sender.send_file_from_path, methods=['GET']) +server.add_url_rule(rule='/api/compress', endpoint='start_compression', view_func=sender.start_compression, methods=['POST']) +server.add_url_rule(rule='/api/compression-progress', endpoint='get_compression_progress', view_func=sender.check_compression_progress, methods=['GET']) diff --git a/components/core/file_sender/sender.py b/components/core/file_sender/sender.py index 20a5c426..6b06255b 100644 --- a/components/core/file_sender/sender.py +++ b/components/core/file_sender/sender.py @@ -1,6 +1,9 @@ from flask import Response, request, send_file, jsonify from DownloadManager import get_id_from_gid, get_download_path, get_download_name_from_id, get_compression_progress import logging +import os +import subprocess +import json from utils.token_utils import token_validator diff --git a/components/core/routes/Download.py b/components/core/routes/Download.py index 7b51485e..6aa1cafa 100644 --- a/components/core/routes/Download.py +++ b/components/core/routes/Download.py @@ -8,7 +8,7 @@ from utils.app_constants import SERVER_SECRET_KEY from utils.token_utils import token_validator from initializer import socketio - +conf = get_conf_reader("dl.conf") def start(): try: @@ -33,7 +33,7 @@ def kill(): p.join() jsonreq = json.dumps({'jsonrpc': '2.0', 'id': 'qwer', 'method': 'aria2.pauseAll'}) jsonreq = jsonreq.encode('ascii') - c = urllib.request.urlopen('http://localhost:6800/jsonrpc', jsonreq) + c = urllib.request.urlopen(conf['aria_server'], jsonreq) if verbose: print(c) if not p.is_alive():