added basic download resuming

This commit is contained in:
Vxrtrauter
2026-01-13 23:51:25 +01:00
parent 5a9d9067b9
commit cc3b201450
3 changed files with 32 additions and 0 deletions
+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_download_log(item, post_url, magnet_uri, False)
add_magnet(magnet_uri) 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.utils.data.state import state
from core.network.aria2_integration import aria2server from core.network.aria2_integration import aria2server
from core.network.aria2_integration import send_notification, update_log 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.shutdown import closehelper, shutdown_event
from core.utils.general.wrappers import run_thread 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 core.utils.config.config import read_config
from PySide6 import QtWidgets from PySide6 import QtWidgets
import qdarktheme import qdarktheme
@@ -37,11 +39,14 @@ def keyboardinterrupthandler(signum, frame):
if __name__ == "__main__": if __name__ == "__main__":
read_config() read_config()
logs = get_download_logs()
count, downloads = split_data(logs)
if args.debug: if args.debug:
state.debug = args.debug # override of read_config 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()
check_completed(downloads, True)
signal.signal(signal.SIGINT, keyboardinterrupthandler) signal.signal(signal.SIGINT, keyboardinterrupthandler)
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True)) 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=update_log, args=(shutdown_event,), daemon=True))