diff --git a/core/downloading/aria2p_server.py b/core/downloading/aria2p_server.py index 01b513c..37e62e5 100644 --- a/core/downloading/aria2p_server.py +++ b/core/downloading/aria2p_server.py @@ -12,10 +12,22 @@ def run_aria2p(): secret="" ) ) + + return aria2 - +def aria2server(): downloads_dir = os.path.join(os.path.expanduser("~"), "Downloads") - subprocess.Popen(["aria2c", "--enable-rpc", "--rpc-listen-all=true", f"--dir={downloads_dir}"]) + + cmd = [ + "aria2c", + "--enable-rpc", + "--disable-ipv6", # added this since it caused problems with vpns + "--rpc-listen-all", + "--rpc-listen-port=6800", + f"--dir={downloads_dir}" + ] + - return aria2 \ No newline at end of file + aria2server = subprocess.Popen(cmd) + return aria2server \ No newline at end of file diff --git a/core/scraping/rutracker_scraper.py b/core/scraping/rutracker_scraper.py index c8f2369..1883c43 100644 --- a/core/scraping/rutracker_scraper.py +++ b/core/scraping/rutracker_scraper.py @@ -1,6 +1,6 @@ import requests -server = "http://vps-e512cfa0.vps.ovh.net:8080" +server = "http://vps-e512cfa0.vps.ovh.net" def scrape_rutracker(search_text, debug): diff --git a/main.py b/main.py index b22937a..b13af50 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,16 @@ from core.ui.gui import MainWindow from core.ui.gui import state_debug - +from core.downloading.aria2p_server import aria2server from PySide6 import QtWidgets import qdarktheme import darkdetect +import subprocess +import signal +import atexit import sys debug = True +aria2process = None def run_gui(): state_debug(debug) @@ -19,5 +23,26 @@ def run_gui(): widget.show() sys.exit(app.exec()) +def kill_aria2server(): + global aria2process + if aria2process: + aria2process.kill() + if debug: + print("\nKilled Aria2") + +def keyboardinterrupthandler(signum, frame): + kill_aria2server() + sys.exit(0) + + + if __name__ == "__main__": + kill_aria2server() + if debug: + print("Starting Aria2 Server") + aria2process = aria2server() + signal.signal(signal.SIGINT, keyboardinterrupthandler) + atexit.register(kill_aria2server) + if debug: + print("Launching GUI") run_gui()