Add basic download logging + fix debug

This commit is contained in:
Vxrtrauter
2026-01-09 23:23:16 +01:00
parent 5eca1a678e
commit 97eabf6ec6
3 changed files with 22 additions and 2 deletions
+16 -1
View File
@@ -29,4 +29,19 @@ def add_download_log(title, url, magnet_uri, completed) -> DownloadList:
with open(downloads_file, "w") as file: with open(downloads_file, "w") as file:
json.dump(asdict(download_list), file, indent=4) json.dump(asdict(download_list), file, indent=4)
return download_list return download_list
def get_download_logs() -> DownloadList:
downloads_file = os.path.join(state.settings_path, "downloads.json")
if os.path.exists(downloads_file) and os.path.getsize(downloads_file) > 0:
try:
with open(downloads_file, "r") as file:
existing_data = json.load(file)
downloads = [Download(**d) for d in existing_data.get("data", [])]
except json.JSONDecodeError:
downloads = []
else:
downloads = []
return DownloadList(data=downloads, count=len(downloads))
+3
View File
@@ -4,6 +4,8 @@ from core.utils.data.tracker import get_magnet_link
from core.network.aria2_wrapper import start_client from core.network.aria2_wrapper import start_client
from core.network.aria2_wrapper import add_magnet from core.network.aria2_wrapper import add_magnet
from core.utils.general.wrappers import run_thread from core.utils.general.wrappers import run_thread
from core.utils.general.logs import add_download_log
import threading import threading
@@ -22,6 +24,7 @@ def run_download(item, posts, post_titles):
print("Selected URL: ", post_url) print("Selected URL: ", post_url)
magnet_uri = get_magnet_link(post_url) magnet_uri = get_magnet_link(post_url)
start_client() start_client()
add_download_log(item, post_url, magnet_uri, False)
add_magnet(magnet_uri) add_magnet(magnet_uri)
+3 -1
View File
@@ -5,6 +5,7 @@ from core.network.aria2_integration import send_notification
from core.utils.general.shutdown import closehelper, shutdown_event from core.utils.general.shutdown import closehelper, shutdown_event
from core.utils.general.wrappers import run_thread from core.utils.general.wrappers import run_thread
from core.utils.config.config import read_config from core.utils.config.config import read_config
from core.utils.general.logs import get_download_logs
from PySide6 import QtWidgets from PySide6 import QtWidgets
import qdarktheme import qdarktheme
import darkdetect import darkdetect
@@ -37,7 +38,8 @@ def keyboardinterrupthandler(signum, frame):
if __name__ == "__main__": if __name__ == "__main__":
read_config() read_config()
state.debug = args.debug # override of read_config if args.debug:
state.debug = args.debug # override of read_config
if state.debug: if state.debug:
print("Starting Aria2 Server") print("Starting Aria2 Server")
state.aria2process = run_aria2server() state.aria2process = run_aria2server()