Compare commits

...

24 Commits

Author SHA1 Message Date
Vxrtrauter 7b2522438c feat: add network interface binding to settings dialog and update save_settings function 2026-02-06 23:50:18 +01:00
Vxrtrauter 0686c7aec2 Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager 2026-02-06 17:52:21 +01:00
Vxrtrauter 6be1784903 feat: add functionality to retrieve and bind IP address of network interfaces 2026-02-06 17:50:42 +01:00
Vxrtrauter 4589322f0a feat: initialize network interface state and log interface details 2026-02-05 19:15:39 +01:00
shayaa 8132d789ef Add activity section to README
Added activity section with analytics image to README.
2026-02-05 17:35:38 +01:00
Vxrtrauter 3f39e67933 Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager 2026-02-05 17:28:50 +01:00
Vxrtrauter d43d6e57cc add more interface stuff 2026-02-05 00:36:12 +01:00
KeksNino 28cffe59f5 feat: add context menu option to delete file 2026-02-04 21:34:03 +01:00
Vxrtrauter f1726f4e9a Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager 2026-02-04 20:44:51 +01:00
KeksNino b7ca895aeb fix: open folder because state.download_path is None in gui.py 2026-02-04 19:35:35 +01:00
KeksNino e95ad11672 add context menu to cancel downloads, open folder and copy magnet link 2026-02-04 18:56:03 +01:00
Vxrtrauter f2a79e5eed test more stuff 2026-02-04 04:04:31 +01:00
Vxrtrauter 990135450f test network stuff 2026-02-04 03:04:24 +01:00
KeksNino 62c6afe350 disable library tab (may be added again in the future) 2026-02-03 17:41:59 +01:00
KeksNino 1aaf56a4dc fix: window transparency on linux/macos 2026-02-03 17:04:09 +01:00
Vxrtrauter 47b643d68b revert all workflow changes 2026-02-02 02:31:00 +01:00
Vxrtrauter de1c8577d6 test new workflow 2026-02-02 02:26:41 +01:00
Vxrtrauter c835b8375c test new workflow 2026-02-02 02:23:52 +01:00
Vxrtrauter e7291e8e99 revert workflow changes 2026-02-02 02:23:22 +01:00
Vxrtrauter a4efe9185a update workflows 2026-02-02 02:18:33 +01:00
Vxrtrauter 86b4f023ac update QApplication instance handling (switch to pyqtdarktheme-fork) 2026-02-02 00:50:32 +01:00
KeksNino 006da55aa0 fix: pause/resume button showing up twice 2026-02-01 20:28:24 +01:00
KeksNino 214a389ad3 fix: if statement to disable windows transparency 2026-02-01 20:14:49 +01:00
KeksNino d4005d7e86 fix: disable transparency on windows as it is broken 2026-01-31 19:17:30 +01:00
11 changed files with 318 additions and 73 deletions
+3
View File
@@ -27,6 +27,9 @@ SoftwareManager is a Python-based GUI/TUI tool that simplifies downloading and m
- If you want to host your own server, clone the server branch of this repo, enter your cookie for rutracker.org and run server.py. Detailed Instructions on how to get your rutracker cookie are in the README of its branch. - If you want to host your own server, clone the server branch of this repo, enter your cookie for rutracker.org and run server.py. Detailed Instructions on how to get your rutracker cookie are in the README of its branch.
- This tool is for educational purposes only. Use it responsibly. - This tool is for educational purposes only. Use it responsibly.
## Activity
![Alt](https://repobeats.axiom.co/api/embed/3a61ea02ffdeb9ed5dd948d974a21e0d6cfae36c.svg "Repobeats analytics image")
## Star History ## Star History
+42 -3
View File
@@ -13,6 +13,7 @@ from PySide6.QtWidgets import (
QSpinBox, QSpinBox,
QCheckBox, QCheckBox,
QFileDialog, QFileDialog,
QComboBox
) )
import platform import platform
@@ -56,7 +57,6 @@ def settings_dialog(self):
autoresume_layout.addStretch() autoresume_layout.addStretch()
autoresume_checkbox.setChecked(state.autoresume) autoresume_checkbox.setChecked(state.autoresume)
autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked))
autoresume_layout.addWidget(autoresume_checkbox) autoresume_layout.addWidget(autoresume_checkbox)
dialog.layout().addWidget(autoresume_container) dialog.layout().addWidget(autoresume_container)
@@ -67,7 +67,7 @@ def settings_dialog(self):
transparent_window_checkbox = QCheckBox() transparent_window_checkbox = QCheckBox()
transparent_window_container.setLayout(transparent_window_layout) transparent_window_container.setLayout(transparent_window_layout)
transparent_window_layout.addWidget(QLabel("Window Transparency (requires restart): ")) transparent_window_layout.addWidget(QLabel("Window Transparency (requires restart) (Linux/MacOS only): "))
transparent_window_layout.addStretch() transparent_window_layout.addStretch()
transparent_window_checkbox.setChecked(state.window_transparency) transparent_window_checkbox.setChecked(state.window_transparency)
@@ -206,6 +206,35 @@ def settings_dialog(self):
max_downloads.setFixedHeight(30) max_downloads.setFixedHeight(30)
dialog.layout().addWidget(max_downloads_container) dialog.layout().addWidget(max_downloads_container)
#####################
# INTERFACE BINDING #
#####################
interface_container = QWidget()
interface_layout = QHBoxLayout()
interface_label = QLabel("Network Interface:")
interface_layout.addWidget(interface_label)
interface_select = QComboBox()
interface_select.addItems(["None"] + state.interfaces)
target = state.bound_interface if state.bound_interface else "None"
index = interface_select.findText(target)
if index >= 0:
interface_select.setCurrentIndex(index)
else:
interface_select.setCurrentIndex(0)
interface_select.setFixedWidth(180)
interface_select.setFixedHeight(30)
interface_select.setFixedWidth(180)
interface_select.setFixedHeight(30)
interface_layout.addWidget(interface_select)
interface_container.setLayout(interface_layout)
dialog.layout().addWidget(interface_container)
############### ###############
# SAVE/CANCEL # # SAVE/CANCEL #
############### ###############
@@ -214,7 +243,17 @@ def settings_dialog(self):
save_btn = QPushButton("Save") save_btn = QPushButton("Save")
cancel_btn = QPushButton("Cancel") cancel_btn = QPushButton("Cancel")
save_btn.clicked.connect(lambda: save_settings(close_settings, api_url.text(), download_path.text(), down_speed_limit.value(), up_speed_limit.value(), image_path.text(), None, max_connections.value(), max_downloads.value())) save_btn.clicked.connect(lambda: save_settings(
close_settings,
api_url.text(),
download_path.text(),
down_speed_limit.value(),
up_speed_limit.value(),
image_path.text(),
autoresume_checkbox.isChecked(),
max_connections.value(),
max_downloads.value(),
interface_select.currentText()))
cancel_btn.clicked.connect(dialog.reject) cancel_btn.clicked.connect(dialog.reject)
layout.addWidget(cancel_btn) layout.addWidget(cancel_btn)
+143 -47
View File
@@ -18,7 +18,7 @@ from PySide6.QtWidgets import (
QStyledItemDelegate, QStyledItemDelegate,
) )
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent
import darkdetect import darkdetect
import threading import threading
import platform import platform
@@ -29,7 +29,7 @@ import libtorrent as lt
import time import time
import sys import sys
import json import json
from core.utils.general.logs import consoleLog from core.utils.general.logs import consoleLog, remove_download_log
from core.utils.general.wrappers import run_thread from core.utils.general.wrappers import run_thread
from core.utils.data.state import state from core.utils.data.state import state
from core.utils.network.download import download_selected from core.utils.network.download import download_selected
@@ -74,7 +74,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def get_asset_path(filename): def get_asset_path(filename):
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS base_path = sys._MEIPASS
else: else:
base_path = os.path.dirname(__file__) base_path = os.path.dirname(__file__)
@@ -134,42 +134,42 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.searchbar.returnPressed.connect(lambda: run_thread(threading.Thread(target=return_pressed, args=(self,)))) # Triggers data function thread on enter self.searchbar.returnPressed.connect(lambda: run_thread(threading.Thread(target=return_pressed, args=(self,)))) # Triggers data function thread on enter
self.dlbutton = QtWidgets.QPushButton("Download") self.dlbutton = QtWidgets.QPushButton("Download")
self.dlbutton.setCursor(Qt.PointingHandCursor) self.dlbutton.setCursor(Qt.CursorShape.PointingHandCursor)
self.libraryList = QListWidget() self.libraryList = QListWidget()
self.emptyResults = QLabel("No Results") self.emptyResults = QLabel("No Results")
self.emptyResults.setAlignment(Qt.AlignCenter) self.emptyResults.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.emptyResults.hide() self.emptyResults.hide()
self.download_model = None self.download_model = None
self.downloadList = QTableView() self.downloadList = QTableView()
self.emptyLibrary = QLabel("No items in library.") self.emptyLibrary = QLabel("No items in library.")
self.emptyDownload = QLabel("No items in downloads.") self.emptyDownload = QLabel("No items in downloads.")
self.emptyDownload.setAlignment(Qt.AlignCenter) self.emptyDownload.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.consoleLog = QTextEdit() self.consoleLog = QTextEdit()
self.progressbar = QProgressBar() self.progressbar = QProgressBar()
# Table Widget for Item List # Table Widget for Item List
self.qtablewidget = QTableWidget() self.qtablewidget = QTableWidget()
self.qtablewidget.setColumnCount(2) self.qtablewidget.setColumnCount(2)
self.qtablewidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.qtablewidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
self.qtablewidget.verticalHeader().setVisible(False) self.qtablewidget.verticalHeader().setVisible(False)
self.qtablewidget.setHorizontalHeaderLabels(["Post Title", "Author"]) self.qtablewidget.setHorizontalHeaderLabels(["Post Title", "Author"])
header = self.qtablewidget.horizontalHeader() header = self.qtablewidget.horizontalHeader()
header.setSectionResizeMode(0, QHeaderView.Stretch) header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
header.setSectionResizeMode(1, QHeaderView.Fixed) header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
header.setStretchLastSection(False) header.setStretchLastSection(False)
self.qtablewidget.setAttribute(Qt.WA_TranslucentBackground) self.qtablewidget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.qtablewidget.viewport().setAttribute(Qt.WA_TranslucentBackground) self.qtablewidget.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
header = self.qtablewidget.horizontalHeader() header = self.qtablewidget.horizontalHeader()
header.setSectionResizeMode(1, QHeaderView.Fixed) header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
header.resizeSection(1, 500) header.resizeSection(1, 500)
container = QWidget() container = QWidget()
@@ -188,32 +188,31 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def columnCount(self, parent=QModelIndex()): def columnCount(self, parent=QModelIndex()):
return len(self.headers) return len(self.headers)
def headerData(self, section, orientation, role=Qt.DisplayRole): def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.DisplayRole and orientation == Qt.Horizontal: if role == Qt.DisplayRole and orientation == Qt.Horizontal:
return self.headers[section] return self.headers[section]
return None return None
def data(self, index, role=Qt.DisplayRole): def data(self, index, role=Qt.DisplayRole):
if role == Qt.DisplayRole: if role == Qt.DisplayRole:
col = index.column() col = index.column()
if index.row() >= len(state.active_downloads) or index.row() < 0: if index.row() >= len(state.active_downloads) or index.row() < 0:
return None return None
magnet_link = list(state.active_downloads.keys())[index.row()] magnet_link = list(state.active_downloads.keys())[index.row()]
magnetdl = state.active_downloads[magnet_link] magnetdl = state.active_downloads[magnet_link]
status = magnetdl.status() status = magnetdl.status()
if col == 0: if col == 0:
is_paused = magnetdl.status().paused pass
return "▶︎" if is_paused else "⏸︎"
elif col == 1: elif col == 1:
return status.name if status.has_metadata else "Fetching metadata..." return status.name if status.has_metadata else "Fetching metadata..."
elif col == 2: elif col == 2:
if status.state == lt.torrent_status.downloading: if status.state == lt.torrent_status.downloading:
return "Downloading" return "Downloading"
elif status.state == lt.torrent_status.seeding: elif status.state == lt.torrent_status.seeding:
return "Seeding" return "Seeding"
elif status.paused: elif status.paused:
return "Paused" return "Paused"
@@ -257,8 +256,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
else: else:
return "" if status.paused else "Stalled" return "" if status.paused else "Stalled"
if role == Qt.UserRole and index.column() == 0: if role == Qt.UserRole and index.column() == 0:
magnet_link = list(state.active_downloads.keys())[index.row()] magnet_link = list(state.active_downloads.keys())[index.row()]
magnetdl = state.active_downloads[magnet_link] magnetdl = state.active_downloads[magnet_link]
return magnetdl.status().paused return magnetdl.status().paused
@@ -269,18 +268,19 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
if row >= len(state.active_downloads) or row < 0: if row >= len(state.active_downloads) or row < 0:
return return
magnet_link = list(state.active_downloads.keys())[row] magnet_link = list(state.active_downloads.keys())[row]
magnetdl = state.active_downloads[magnet_link] magnetdl = state.active_downloads[magnet_link]
status = magnetdl.status() status = magnetdl.status()
if status.state == lt.torrent_status.seeding: if status.state == lt.torrent_status.seeding:
if state.download_path is not None and os.path.exists(state.download_path): save_path = magnetdl.save_path()
if save_path and os.path.exists(save_path):
if platform.system() == "Windows": if platform.system() == "Windows":
os.startfile(os.path.normpath(state.download_path)) os.startfile(os.path.normpath(save_path))
elif platform.system() == "Linux": elif platform.system() == "Linux":
subprocess.Popen(["xdg-open", state.download_path]) subprocess.Popen(["xdg-open", save_path])
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
subprocess.Popen(["open", state.download_path]) subprocess.Popen(["open", save_path])
return return
if status.paused: if status.paused:
@@ -299,18 +299,18 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
button = editor.findChild(QtWidgets.QPushButton) button = editor.findChild(QtWidgets.QPushButton)
magnet_link = list(state.active_downloads.keys())[index.row()] magnet_link = list(state.active_downloads.keys())[index.row()]
magnetdl = state.active_downloads[magnet_link] magnetdl = state.active_downloads[magnet_link]
status = magnetdl.status() status = magnetdl.status()
if button: if button:
if status.state == lt.torrent_status.seeding: if status.state == lt.torrent_status.seeding:
button.setText("📁") button.setText("📁")
else: else:
button.setText("▶︎" if status.paused else "⏸︎") button.setText("▶︎" if status.paused else "⏸︎")
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
magnet_link = list(state.active_downloads.keys())[index.row()] magnet_link = list(state.active_downloads.keys())[index.row()]
magnetdl = state.active_downloads[magnet_link] magnetdl = state.active_downloads[magnet_link]
status = magnetdl.status() status = magnetdl.status()
@@ -318,7 +318,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
widget.setStyleSheet("border: none;") widget.setStyleSheet("border: none;")
layout = QHBoxLayout(widget) layout = QHBoxLayout(widget)
layout.setContentsMargins(0, 0, 0, 0) layout.setContentsMargins(0, 0, 0, 0)
if status.state == lt.torrent_status.seeding: if status.state == lt.torrent_status.seeding:
btnPause = QtWidgets.QPushButton("📁") btnPause = QtWidgets.QPushButton("📁")
else: else:
btnPause = QtWidgets.QPushButton("▶︎" if status.paused else "⏸︎") btnPause = QtWidgets.QPushButton("▶︎" if status.paused else "⏸︎")
@@ -329,7 +329,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
layout.addStretch() layout.addStretch()
widget.setLayout(layout) widget.setLayout(layout)
return widget return widget
def editorEvent(self, event, model, option, index): def editorEvent(self, event, model, option, index):
if index.column() == 0 and event.type() == QEvent.Type.MouseButtonPress: if index.column() == 0 and event.type() == QEvent.Type.MouseButtonPress:
self.clicked.emit(index.row()) self.clicked.emit(index.row())
@@ -339,10 +338,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.download_model = DownloadModel() self.download_model = DownloadModel()
self.downloadList.setModel(self.download_model) self.downloadList.setModel(self.download_model)
self.downloadList.horizontalHeader().setStretchLastSection(False) self.downloadList.horizontalHeader().setStretchLastSection(False)
self.downloadList.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.downloadList.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.downloadList.setSelectionBehavior(QTableView.SelectRows) self.downloadList.setSelectionBehavior(QTableView.SelectionBehavior.SelectRows)
self.downloadList.setAttribute(Qt.WA_TranslucentBackground) self.downloadList.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground) self.downloadList.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
download_model = self.download_model download_model = self.download_model
@@ -378,7 +377,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.horizontal_layout.addWidget(self.qtablewidget) self.horizontal_layout.addWidget(self.qtablewidget)
self.tab1 = create_tab("Search", self.searchbar, self.qtablewidget, self.tabs, self.dlbutton, self.horizontal_layout) self.tab1 = create_tab("Search", self.searchbar, self.qtablewidget, self.tabs, self.dlbutton, self.horizontal_layout)
self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None) # self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None)
self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None) self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None)
if state.image_path is not None and os.path.exists(state.image_path): if state.image_path is not None and os.path.exists(state.image_path):
@@ -406,7 +405,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.tracker_list = QComboBox() self.tracker_list = QComboBox()
self.tracker_list.addItems(["rutracker", "uztracker", "m0nkrus"]) self.tracker_list.addItems(["rutracker", "uztracker", "m0nkrus"])
self.tracker_list.setCursor(Qt.PointingHandCursor) self.tracker_list.setCursor(Qt.CursorShape.PointingHandCursor)
self.tracker_list.activated.connect(self.set_tracker) self.tracker_list.activated.connect(self.set_tracker)
self.corner_layout.addWidget(self.tracker_list) self.corner_layout.addWidget(self.tracker_list)
@@ -418,16 +417,11 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
else: else:
self.settings_btn.setIcon(QIcon(get_asset_path("settings_black.png"))) self.settings_btn.setIcon(QIcon(get_asset_path("settings_black.png")))
self.settings_btn.setToolTip("Settings") self.settings_btn.setToolTip("Settings")
self.settings_btn.setCursor(Qt.PointingHandCursor) self.settings_btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.settings_btn.clicked.connect(lambda: settings_dialog(self)) self.settings_btn.clicked.connect(lambda: settings_dialog(self))
self.corner_layout.addWidget(self.settings_btn) self.corner_layout.addWidget(self.settings_btn)
self.tab_wrapper = QWidget() self.tab_wrapper = QWidget()
self.tab_layout = QVBoxLayout() self.tab_layout = QVBoxLayout()
self.tab_layout.setContentsMargins(0, 0, 0, 0) self.tab_layout.setContentsMargins(0, 0, 0, 0)
@@ -464,6 +458,12 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.active_timer.timeout.connect(self.show_empty_downloads) self.active_timer.timeout.connect(self.show_empty_downloads)
self.active_timer.start(500) self.active_timer.start(500)
self.context_menu = QtWidgets.QMenu(self)
self.context_menu.addAction("Open Containing Folder", self.openFolderAction)
self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction)
self.context_menu.addAction("Cancel Download", self.cancelDownloadAction)
self.context_menu.addAction("Delete File", self.deleteFileAction)
@staticmethod @staticmethod
def add_log(text): def add_log(text):
if MainWindow._instance: if MainWindow._instance:
@@ -520,3 +520,99 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
super().resizeEvent(event) super().resizeEvent(event)
table_width = self.qtablewidget.viewport().width() table_width = self.qtablewidget.viewport().width()
self.qtablewidget.setColumnWidth(1, int(table_width * 0.3)) self.qtablewidget.setColumnWidth(1, int(table_width * 0.3))
def contextMenuEvent(self, event: QContextMenuEvent):
if self.downloadList.underMouse():
pos = self.downloadList.viewport().mapFromGlobal(event.globalPos())
index = self.downloadList.indexAt(pos)
if index.isValid():
row = index.row()
self._context_menu_row = row
self.context_menu.exec(event.globalPos())
else:
super().contextMenuEvent(event)
def openFolderAction(self):
if not hasattr(self, '_context_menu_row'):
return
row = self._context_menu_row
if row < 0 or row >= len(state.active_downloads):
return
magnet_link = list(state.active_downloads.keys())[row]
magnetdl = state.active_downloads[magnet_link]
download_path = magnetdl.save_path()
if download_path and os.path.exists(download_path):
if platform.system() == "Windows":
os.startfile(os.path.normpath(download_path))
elif platform.system() == "Linux":
subprocess.Popen(["xdg-open", download_path])
elif platform.system() == "Darwin":
subprocess.Popen(["open", download_path])
def copyMagnetURIAction(self):
if not hasattr(self, '_context_menu_row'):
return
row = self._context_menu_row
if row < 0 or row >= len(state.active_downloads):
return
magnet_link = list(state.active_downloads.keys())[row]
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(magnet_link)
def cancelDownloadAction(self):
if not hasattr(self, '_context_menu_row'):
return
row = self._context_menu_row
if row < 0 or row >= len(state.active_downloads):
return
magnet_link = list(state.active_downloads.keys())[row]
magnetdl = state.active_downloads[magnet_link]
confirm = QMessageBox.question(self, "Cancel Download", f"Are you sure you want to cancel the download of '{magnetdl.status().name}'?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
if confirm == QMessageBox.StandardButton.Yes:
del state.active_downloads[magnet_link]
remove_download_log(magnet_link)
consoleLog(f"Cancelled download: {magnetdl.status().name}", True)
def deleteFileAction(self):
if not hasattr(self, '_context_menu_row'):
return
row = self._context_menu_row
if row < 0 or row >= len(state.active_downloads):
return
magnet_link = list(state.active_downloads.keys())[row]
magnetdl = state.active_downloads[magnet_link]
status = magnetdl.status()
save_path = status.save_path
torrent_name = status.name
download_path = os.path.join(save_path, torrent_name)
confirm = QMessageBox.question(self, "Delete Files", f"Are you sure you want to delete the downloaded files of '{magnetdl.status().name}'? This action cannot be undone.", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
if confirm == QMessageBox.StandardButton.Yes:
if download_path and os.path.exists(download_path):
try:
if os.path.isfile(download_path):
os.remove(download_path)
del state.active_downloads[magnet_link]
remove_download_log(magnet_link)
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
else:
import shutil
shutil.rmtree(download_path)
del state.active_downloads[magnet_link]
remove_download_log(magnet_link)
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
except Exception as e:
consoleLog(f"Error deleting files: {e}", True)
+52
View File
@@ -0,0 +1,52 @@
from core.utils.general.logs import consoleLog
from core.utils.data.state import state
import psutil
addrs = psutil.net_if_addrs()
stats = psutil.net_if_stats()
def get_net_interfaces():
for interface in addrs.keys():
consoleLog(f"Found Interface: {interface}")
return addrs.keys()
def get_active_interfaces():
active = []
for interface, addr_list in addrs.items():
up = stats[interface].isup
for addr in addr_list:
if addr.family == 2: # ipv4
ipv4 = addr.address
if not ipv4.startswith("127.") and not ipv4.startswith("169.254") and up == True:
active.append(interface)
consoleLog(f"Found Active: {interface}")
return active
def list_interfaces() -> None:
for interface, addr_list in addrs.items():
up = stats[interface].isup
for addr in addr_list:
if addr.family == 2: # ipv4
ipv4 = addr.address
if not ipv4.startswith("127.") and not ipv4.startswith("169.254") and up == True:
status = "ACTIVE"
else:
status = "INACTIVE"
consoleLog(f"Found Interface: {interface} [{status}]")
def init_interfaces():
state.interfaces = list(addrs.keys())
state.active_interfaces = get_active_interfaces()
def get_interface_ip(interface_name):
if interface_name in addrs:
for addr in addrs[interface_name]:
if addr.family == 2: # ipv4
if not addr.address.startswith("127.") and not addr.address.startswith("169.254"):
return addr.address
return None
+25 -2
View File
@@ -1,5 +1,6 @@
import time import time
from core.utils.general.wrappers import run_thread from core.utils.general.wrappers import run_thread
from core.network.interface import get_interface_ip
import threading import threading
import libtorrent as lt import libtorrent as lt
from core.utils.data.state import state from core.utils.data.state import state
@@ -15,6 +16,7 @@ def init_session():
state.dl_session = lt.session() state.dl_session = lt.session()
settings = { settings = {
"upload_rate_limit": state.up_speed_limit, "upload_rate_limit": state.up_speed_limit,
"download_rate_limit": state.down_speed_limit, "download_rate_limit": state.down_speed_limit,
@@ -26,8 +28,15 @@ def init_session():
"connections_limit": state.max_connections, "connections_limit": state.max_connections,
"active_downloads": state.max_downloads "active_downloads": state.max_downloads
} }
if state.bound_interface:
interface_ip = get_interface_ip(state.bound_interface)
if interface_ip:
settings["outgoing_interfaces"] = interface_ip
settings["listen_interfaces"] = f"{interface_ip}:6881"
consoleLog(f"Binding to Interface IP: {interface_ip}")
else:
consoleLog(f"Error finding IP for Interface {state.bound_interface}")
state.dl_session.apply_settings(settings) state.dl_session.apply_settings(settings)
@@ -45,7 +54,6 @@ def add_download(magnet_uri, dl_path=state.download_path):
consoleLog("Skipping, download already running...") consoleLog("Skipping, download already running...")
return return
magnetdl = lt.parse_magnet_uri(magnet_uri) magnetdl = lt.parse_magnet_uri(magnet_uri)
magnetdl.save_path = dl_path magnetdl.save_path = dl_path
@@ -98,6 +106,21 @@ def update_settings():
"connections_limit": state.max_connections, "connections_limit": state.max_connections,
"active_downloads": state.max_downloads "active_downloads": state.max_downloads
} }
if state.bound_interface:
interface_ip = get_interface_ip(state.bound_interface)
if interface_ip:
settings["outgoing_interfaces"] = interface_ip
settings["listen_interfaces"] = f"{interface_ip}:6881"
consoleLog(f"Binding to Interface IP: {interface_ip}")
else:
consoleLog(f"Error finding IP for Interface {state.bound_interface}")
state.dl_session.apply_settings(settings) state.dl_session.apply_settings(settings)
def update_bound_interface():
settings = { "outgoing_interfaces": state.bound_interface }
state.dl_session.apply_settings(settings)
+1 -4
View File
@@ -6,7 +6,4 @@ def add_magnet(uri):
add_download(uri) add_download(uri)
consoleLog("Magnet URI added to LibTorrent") consoleLog("Magnet URI added to LibTorrent")
else: else:
consoleLog(f"Invalid Magnet Link: {uri}") consoleLog(f"Invalid Magnet Link: {uri}")
+3 -1
View File
@@ -4,7 +4,7 @@ from core.utils.general.logs import consoleLog
from .config import create_config from .config import create_config
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None): def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None):
if apiurl is not None: if apiurl is not None:
state.api_url = apiurl state.api_url = apiurl
if download_path is not None: if download_path is not None:
@@ -21,6 +21,8 @@ def save_settings(close=lambda: None, apiurl=None, download_path=None, down_spee
state.max_connections = max_connections state.max_connections = max_connections
if max_downloads is not None: if max_downloads is not None:
state.max_downloads = max_downloads state.max_downloads = max_downloads
if bound_interface is not None:
state.bound_interface = None if bound_interface == "None" else bound_interface
update_settings() update_settings()
+4 -1
View File
@@ -23,10 +23,13 @@ class AppState(QObject):
self.down_speed_limit: int = 0 self.down_speed_limit: int = 0
self.max_connections: int = 200 self.max_connections: int = 200
self.max_downloads: int = 10 self.max_downloads: int = 10
self.settings_path: str = None self.settings_path: str = ""
self.dl_session: Any = None self.dl_session: Any = None
self.active_downloads: List[str] = {} self.active_downloads: List[str] = {}
self.window_transparency: bool = False self.window_transparency: bool = False
self.interfaces: List = []
self.active_interfaces: List = []
self.bound_interface: str = None
@property @property
def image_path(self) -> str: def image_path(self) -> str:
+25 -1
View File
@@ -41,6 +41,30 @@ def add_download_log(title, url, magnet_uri, completed) -> DownloadList:
return download_list return download_list
def remove_download_log(magnet_uri) -> DownloadList:
downloads_file = os.path.join(state.settings_path, "downloads.json")
if os.path.exists(downloads_file) and os.path.getsize(downloads_file) > 0:
try:
with open(downloads_file, "r") as file:
existing_data = json.load(file)
downloads = [Download(**d) for d in existing_data.get("data", [])]
except json.JSONDecodeError:
downloads = []
else:
downloads = []
magnet_link = (magnet_uri or "").strip()
downloads = [d for d in downloads if (getattr(d, 'magnet_uri', None) or "").strip() != magnet_link and (getattr(d, 'url', None) or "").strip() != magnet_link]
consoleLog(f"Removed {magnet_link} from Log File")
download_list = DownloadList(data=downloads, count=len(downloads))
with open(downloads_file, "w") as file:
json.dump(asdict(download_list), file, indent=4)
return download_list
def update_download_completed(magnet_uri, completed) -> DownloadList: def update_download_completed(magnet_uri, completed) -> DownloadList:
downloads_file = os.path.join(state.settings_path, "downloads.json") downloads_file = os.path.join(state.settings_path, "downloads.json")
@@ -176,4 +200,4 @@ def consoleLog(text, printAnyways = False):
pass pass
if state.debug or printAnyways: if state.debug or printAnyways:
print(f"[{current_time}] {text}") print(f"[{current_time}] {text}")
+19 -13
View File
@@ -6,33 +6,34 @@ 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.general.loghandler import split_data, check_completed
from core.network.interface import list_interfaces, init_interfaces
from core.network.libtorrent_int import update_bound_interface
from core.utils.config.config import read_config from core.utils.config.config import read_config
from PySide6 import QtWidgets from PySide6 import QtWidgets
from PySide6.QtCore import Qt from PySide6.QtCore import Qt
import qdarktheme import qdarktheme
import threading import threading
import platform
import signal import signal
import argparse import argparse
import sys import sys
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--debug", action="store_true") parser.add_argument("--debug", action="store_true")
args = parser.parse_args() args = parser.parse_args()
def run_gui(): def run_gui():
app = QtWidgets.QApplication([]) app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
qdarktheme.setup_theme("auto")
widget = MainWindow() widget = MainWindow()
if state.window_transparency is True:
qdarktheme.setup_theme("auto", custom_colors={"background": "#00000000"}) if state.window_transparency and platform.system() != "Windows":
widget.setWindowFlags(Qt.WindowType.FramelessWindowHint)
widget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) widget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
else: qdarktheme.setup_theme("auto", custom_colors={"background": "#00000000"})
qdarktheme.setup_theme("auto")
from core.utils.general.logs import set_main_window from core.utils.general.logs import set_main_window
set_main_window(widget) set_main_window(widget)
widget.show() widget.show()
sys.exit(app.exec()) sys.exit(app.exec())
@@ -46,12 +47,17 @@ if __name__ == "__main__":
if args.debug: if args.debug:
state.debug = args.debug # override of read_config state.debug = args.debug # override of read_config
signal.signal(signal.SIGINT, keyboardinterrupthandler) signal.signal(signal.SIGINT, keyboardinterrupthandler)
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
consoleLog("Started send_notification thread")
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
consoleLog("Started update_log thread")
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
consoleLog("Started check_completed thread") consoleLog("Started check_completed thread")
consoleLog("Fetching Network Interfaces...")
list_interfaces()
consoleLog("Initialiting Interface variables...")
init_interfaces()
consoleLog(f"Current Bound: {state.bound_interface}")
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
consoleLog("Started Thread: send_notification")
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
consoleLog("Started Thread: update_log")
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
consoleLog("Launching GUI") consoleLog("Launching GUI")
run_gui() run_gui()
+1 -1
View File
@@ -3,7 +3,7 @@ PySide6==6.10.1
beautifulsoup4==4.13.5 beautifulsoup4==4.13.5
darkdetect==0.7.1 darkdetect==0.7.1
pyinstaller==6.15.0 pyinstaller==6.15.0
pyqtdarktheme==2.1.0 PyQtDarkTheme-fork==2.3.4
aiohttp==3.13.0 aiohttp==3.13.0
plyer==2.1.0 plyer==2.1.0
psutil==7.1.0 psutil==7.1.0