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:
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))