feat: implement seeding functionality and enhance download management with seeded magnets tracking

This commit is contained in:
Vxrtrauter
2026-03-08 12:00:00 +01:00
parent dcc12c0b28
commit 8d1b3ba68f
5 changed files with 28 additions and 3 deletions
+18
View File
@@ -84,6 +84,24 @@ def add_download(magnet_uri, dl_path=state.download_path):
return True
def add_seed(magnet_uri, file_path):
if state.active_downloads is None:
state.active_downloads = {}
init_session()
if magnet_uri in state.active_downloads:
consoleLog("Already seeding this torrent")
return False
magnetdl = lt.parse_magnet_uri(magnet_uri)
magnetdl.save_path = os.path.dirname(file_path)
handle = state.dl_session.add_torrent(magnetdl)
state.active_downloads[magnet_uri] = handle
state.seeded_magnets.add(magnet_uri)
return True
def dl_status_loop():
global loop_running
+1 -1
View File
@@ -51,7 +51,7 @@ def update_log(shutdown_event):
status = magnetdl.status()
if status.state == lt.torrent_status.seeding and magnet_uri not in updated:
if status.state == lt.torrent_status.seeding and magnet_uri not in updated and magnet_uri not in state.seeded_magnets:
consoleLog(f"Marking {status.name} as completed")
info_hash = str(status.info_hash)
update_download_completed_by_hash(info_hash, True)