add basic libtorrent integration

This commit is contained in:
Vxrtrauter
2026-01-30 21:31:30 +01:00
parent 1da62ef414
commit b217a74fce
2 changed files with 45 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import subprocess
import libtorrent as lt
from core.utils.data.state import state
from core.utils.general.logs import consoleLog
def init_session():
if state.dl_session is not None:
return
state.dl_session = lt.session()
settings = {
"upload_rate_limit": 0,
"download_rate_limit": 0,
"enable_dht": True,
"enable_lsd": True,
"enable_upnp": True,
"enable_natpmp": True,
"dht_bootstrap_nodes": "router.bittorrent.com:6881,dht.transmissionbt.com:6881",
"connections_limit": 200,
"active_downloads": 10
}
state.dl_session.apply_settings(settings)
def add_download(magnet_uri, dl_path=state.download_path):
init_session()
if magnet_uri in state.active_downloads:
consoleLog("Skipping, download already running...")
return
consoleLog(f"Adding {magnet_uri} to downloads...")
magnetdl = lt.parse_magnet_uri(magnet_uri)
magnetdl.save_path = dl_path
download = state.dl_session.add_torrent(magnetdl)
state.active_downloads[magnet_uri] = magnetdl
+2
View File
@@ -26,6 +26,8 @@ class AppState(QObject):
self.aria2p: Any = None
self.aria2_threads: int = 4
self.settings_path: str = None
self.dl_session: Any = None
self.active_downloads: Any = None
@property
def image_path(self) -> str: