From a9450435d7c9d75f82086b9628a4489438697019 Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Sat, 11 Oct 2025 20:35:21 +0200 Subject: [PATCH] fixed error messages spamming in console + added debug messages --- core/interface/gui.py | 4 +++- core/network/aria2_integration.py | 9 +++++---- core/utils/data/state.py | 4 ++-- core/utils/data/tracker.py | 2 +- core/utils/network/jsonhandler.py | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/interface/gui.py b/core/interface/gui.py index 2baf406..012f929 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -259,12 +259,14 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.softwareList.addItems(state.post_titles) self.post_author_list.addItems(state.post_author) if state.tracker == "rutracker": - _, state.posts, _, _ = split_data(response) + _, state.posts, _, _, cached = split_data(response) state.post_titles, _, state.post_author = format_data(state.posts) self.post_author_list.clear() self.post_author_list.addItems(state.post_author) self.softwareList.clear() self.softwareList.addItems(state.post_titles) + if state.debug == True: + print(f"Cached: {cached}") if not response: if state.debug: print(f"No Results found for \"{search_text}\"") diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 414cf90..5669ca1 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -49,14 +49,15 @@ def dlprogress(): return 0 def send_notification(): + while True: try: - for d in state.aria2.get_downloads(): + for download in state.aria2: if dlprogress() == 100: notification.notify( - title="Download finished", - message=f"{d.name} has finished downloading.", - timeout=4 + title = "Download finished", + message = f"{download.name} has finished downloading.", + timeout = 4 ) except Exception as e: if state.debug: diff --git a/core/utils/data/state.py b/core/utils/data/state.py index 6dd989d..cba4e03 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Optional, Any, List, Dict from pathlib import Path @@ -14,7 +14,7 @@ class AppState: download_path: str = str(Path.home() / "Downloads") speed_limit: int = 0 aria2process: Optional[Any] = None - aria2: Optional[Any] = None + aria2: list[Any] = field(default_factory=list) aria2_threads: int = 4 state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], download_path="") diff --git a/core/utils/data/tracker.py b/core/utils/data/tracker.py index 247abb6..27e7f27 100644 --- a/core/utils/data/tracker.py +++ b/core/utils/data/tracker.py @@ -21,7 +21,7 @@ def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list def get_magnet_link(post_url): try: - response = requests.get(post_url) + response = requests.get(post_url) # eventually impl. cloudscraper response.raise_for_status() soup = BeautifulSoup(response.text, 'html.parser') magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:')) diff --git a/core/utils/network/jsonhandler.py b/core/utils/network/jsonhandler.py index 23ca59f..7055515 100644 --- a/core/utils/network/jsonhandler.py +++ b/core/utils/network/jsonhandler.py @@ -7,8 +7,9 @@ def split_data(data): posts = p_json["data"] query = p_json["query"] success = p_json["success"] + cached = p_json["cached"] - return count, posts, query, success + return count, posts, query, success, cached def format_data(data): post_author = [post["author"] for post in data]