Compare commits

...

4 Commits

Author SHA1 Message Date
Vxrtrauter 9afced8a0b Add auto-resume functionality and update settings dialog 2026-01-14 00:18:39 +01:00
Vxrtrauter db77bed3cf add autoresume variable functionality 2026-01-13 23:58:23 +01:00
Vxrtrauter cc3b201450 added basic download resuming 2026-01-13 23:51:25 +01:00
Vxrtrauter 5a9d9067b9 fix exception spam 2026-01-13 21:35:03 +01:00
8 changed files with 67 additions and 17 deletions
+25 -10
View File
@@ -28,18 +28,33 @@ def settings_dialog(self):
def close_settings():
dialog.reject()
checkbox_container = QWidget()
checkbox_layout = QHBoxLayout()
update_checkbox_container = QWidget()
update_checkbox_layout = QHBoxLayout()
# ignore updates checkbox
checkbox = QCheckBox()
checkbox_container.setLayout(checkbox_layout)
checkbox_layout.addWidget(QLabel("Ignore Updates: "))
checkbox_layout.addStretch()
checkbox.setChecked(state.ignore_updates)
checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
checkbox_layout.addWidget(checkbox)
dialog.layout().addWidget(checkbox_container)
update_checkbox = QCheckBox()
update_checkbox_container.setLayout(update_checkbox_layout)
update_checkbox_layout.addWidget(QLabel("Ignore Updates: "))
update_checkbox_layout.addStretch()
update_checkbox.setChecked(state.ignore_updates)
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
update_checkbox_layout.addWidget(update_checkbox)
dialog.layout().addWidget(update_checkbox_container)
# auto-resume downloads checkbox
autoresume_container = QWidget()
autoresume_layout = QHBoxLayout()
autoresume_checkbox = QCheckBox()
autoresume_container.setLayout(autoresume_layout)
autoresume_layout.addWidget(QLabel("Auto-Resume Downloads: "))
autoresume_layout.addStretch()
autoresume_checkbox.setChecked(state.autoresume)
autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked))
autoresume_layout.addWidget(autoresume_checkbox)
dialog.layout().addWidget(autoresume_container)
##################
# THREAD SETTING #
+2 -5
View File
@@ -88,9 +88,6 @@ def update_log(shutdown_event):
update_download_completed_by_hash(d.info_hash, True)
updated.add(d.gid)
state.downloads = [d for d in state.aria2.get_downloads() if d.is_active and not d.is_metadata]
except Exception as e:
if state.debug:
print(f"Error in update_log: {e}")
import traceback
traceback.print_exc()
except Exception:
pass
time.sleep(5)
+3 -1
View File
@@ -7,7 +7,7 @@ def create_config():
config = configparser.ConfigParser()
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}",
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}"}
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}", "autoresume": f"{state.autoresume}"}
if platform.system() == "Windows":
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
@@ -51,3 +51,5 @@ def read_config():
state.ignore_updates = config.getboolean("General", "ignore_updates")
if state.image_path is not None:
state.image_path = config.get("General", "image_path")
if state.autoresume is not None:
state.autoresume = config.getboolean("General", "autoresume")
+4 -1
View File
@@ -13,7 +13,7 @@ def restart_aria2c():
atexit.unregister(kill_aria2server)
atexit.register(kill_aria2server)
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, image_path=None):
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, image_path=None, autoresume=None):
if thread_count is not None:
state.aria2_threads = thread_count
if apiurl is not None:
@@ -24,6 +24,9 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p
state.speed_limit = speed_limit
if image_path is not None:
state.image_path = image_path
if autoresume is not None:
state.autoresume = autoresume
create_config()
restart_aria2c()
+1
View File
@@ -16,6 +16,7 @@ class AppState(QObject):
self._image_path: str = ""
self.ignore_updates: bool = False
self.debug: bool = False
self.autoresume: bool = True
self.tracker: str = "rutracker"
self.api_url: str = "https://api.michijackson.xyz"
self.download_path: str = str(Path.home() / "Downloads")
+23
View File
@@ -0,0 +1,23 @@
from core.utils.data.state import state
from core.utils.network.download import run_download_direct
def split_data(data):
count = data.count
downloads = data.data
return count, downloads
def check_completed(downloads, resume):
for download in downloads:
if download.completed == False:
if state.debug:
print(f"Found unfinished download: {download.title}")
if resume == True:
run_download_direct(download.magnet_uri)
if state.debug:
print(f"Resuming {download.title}")
+4
View File
@@ -27,5 +27,9 @@ def run_download(item, posts, post_titles):
add_download_log(item, post_url, magnet_uri, False)
add_magnet(magnet_uri)
def run_download_direct(magnet_uri):
start_client()
add_magnet(magnet_uri)
+5
View File
@@ -2,8 +2,10 @@ from core.interface.gui import MainWindow
from core.utils.data.state import state
from core.network.aria2_integration import aria2server
from core.network.aria2_integration import send_notification, update_log
from core.utils.general.logs import get_download_logs
from core.utils.general.shutdown import closehelper, shutdown_event
from core.utils.general.wrappers import run_thread
from core.utils.general.loghandler import split_data, check_completed
from core.utils.config.config import read_config
from PySide6 import QtWidgets
import qdarktheme
@@ -37,6 +39,8 @@ def keyboardinterrupthandler(signum, frame):
if __name__ == "__main__":
read_config()
logs = get_download_logs()
count, downloads = split_data(logs)
if args.debug:
state.debug = args.debug # override of read_config
if state.debug:
@@ -45,6 +49,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGINT, keyboardinterrupthandler)
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
if state.debug:
print("Launching GUI")
run_gui()