mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 01:49:42 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d1a639651 | |||
| 8d1b3ba68f |
@@ -10,7 +10,6 @@ from PySide6.QtWidgets import (
|
|||||||
QHBoxLayout,
|
QHBoxLayout,
|
||||||
QComboBox,
|
QComboBox,
|
||||||
QTabWidget,
|
QTabWidget,
|
||||||
QProgressBar,
|
|
||||||
QHeaderView,
|
QHeaderView,
|
||||||
QMessageBox,
|
QMessageBox,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
@@ -143,7 +142,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.emptyDownload.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
self.emptyDownload.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
|
|
||||||
self.consoleLog = QTextEdit()
|
self.consoleLog = QTextEdit()
|
||||||
self.progressbar = QProgressBar()
|
|
||||||
|
|
||||||
flush_log_buffer()
|
flush_log_buffer()
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,24 @@ def add_download(magnet_uri, dl_path=state.download_path):
|
|||||||
return True
|
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():
|
def dl_status_loop():
|
||||||
global loop_running
|
global loop_running
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def update_log(shutdown_event):
|
|||||||
|
|
||||||
status = magnetdl.status()
|
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")
|
consoleLog(f"Marking {status.name} as completed")
|
||||||
info_hash = str(status.info_hash)
|
info_hash = str(status.info_hash)
|
||||||
update_download_completed_by_hash(info_hash, True)
|
update_download_completed_by_hash(info_hash, True)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class AppState(QObject):
|
|||||||
self.settings_path: str = ""
|
self.settings_path: str = ""
|
||||||
self.dl_session: Any = None
|
self.dl_session: Any = None
|
||||||
self.active_downloads: Dict = {}
|
self.active_downloads: Dict = {}
|
||||||
|
self.seeded_magnets: set = set()
|
||||||
self.window_transparency: bool = False
|
self.window_transparency: bool = False
|
||||||
self.interfaces: List = []
|
self.interfaces: List = []
|
||||||
self.active_interfaces: List = []
|
self.active_interfaces: List = []
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from core.utils.logging.logs import consoleLog, remove_download_log
|
from core.utils.logging.logs import consoleLog, remove_download_log
|
||||||
from core.utils.network.download import run_download_direct
|
from core.utils.network.download import run_download_direct, seed_magnet
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ def check_downloads(downloads):
|
|||||||
for download in downloads:
|
for download in downloads:
|
||||||
if os.path.exists(download.path):
|
if os.path.exists(download.path):
|
||||||
consoleLog(f"Existing Download: {download.title}")
|
consoleLog(f"Existing Download: {download.title}")
|
||||||
|
seed_magnet(download.magnet_uri, download.path)
|
||||||
else:
|
else:
|
||||||
consoleLog(f"Inexistent Download: {download.title}")
|
consoleLog(f"Inexistent Download: {download.title}")
|
||||||
remove_download_log(download.magnet_uri)
|
remove_download_log(download.magnet_uri)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from core.utils.data.tracker import get_magnet_link
|
|||||||
from core.network.libtorrent_wrapper import add_download
|
from core.network.libtorrent_wrapper import add_download
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.logging.logs import add_download_log
|
from core.utils.logging.logs import add_download_log
|
||||||
|
from core.network.libtorrent_int import add_seed
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
@@ -26,3 +27,7 @@ def run_download_direct(magnet_uri):
|
|||||||
consoleLog(f"Direct download: {magnet_uri[:60]}")
|
consoleLog(f"Direct download: {magnet_uri[:60]}")
|
||||||
add_download(magnet_uri)
|
add_download(magnet_uri)
|
||||||
add_download_log("Direct Download", "", magnet_uri, False)
|
add_download_log("Direct Download", "", magnet_uri, False)
|
||||||
|
|
||||||
|
def seed_magnet(magnet_uri, file_path):
|
||||||
|
consoleLog(f"Seeding: {magnet_uri[:60]}")
|
||||||
|
add_seed(magnet_uri, file_path)
|
||||||
Reference in New Issue
Block a user