mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 01:49:42 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f39e67933 | |||
| d43d6e57cc | |||
| 28cffe59f5 | |||
| f1726f4e9a | |||
| b7ca895aeb | |||
| e95ad11672 | |||
| f2a79e5eed | |||
| 990135450f | |||
| 62c6afe350 | |||
| 1aaf56a4dc | |||
| 47b643d68b |
+11
-17
@@ -28,8 +28,8 @@ jobs:
|
|||||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-linux
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||||
asset_name: SoftwareManager-dev-${{ github.sha }}-linux
|
asset_name: SoftwareManager-dev-${{ github.sha }}-linux
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-windows.zip
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||||
asset_name: SoftwareManager-dev-${{ github.sha }}-windows.zip
|
asset_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
artifact_name: SoftwareManager-dev-${{ github.sha }}-macos
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||||
asset_name: SoftwareManager-dev-${{ github.sha }}-macos
|
asset_name: SoftwareManager-dev-${{ github.sha }}-macos
|
||||||
@@ -86,7 +86,7 @@ jobs:
|
|||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
pyinstaller --onedir --windowed \
|
pyinstaller --onefile --windowed \
|
||||||
--add-data "build_info.json;." \
|
--add-data "build_info.json;." \
|
||||||
--add-data "build_info.json;core" \
|
--add-data "build_info.json;core" \
|
||||||
--add-data "build_info.json;core/interface" \
|
--add-data "build_info.json;core/interface" \
|
||||||
@@ -122,21 +122,15 @@ jobs:
|
|||||||
--name ${{ env.APP_NAME }} \
|
--name ${{ env.APP_NAME }} \
|
||||||
main.py
|
main.py
|
||||||
|
|
||||||
- name: Package and rename artifact (Windows)
|
- name: Make executable (Unix)
|
||||||
if: runner.os == 'Windows'
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
cd dist
|
|
||||||
Compress-Archive -Path '${{ env.APP_NAME }}' -DestinationPath '${{ matrix.artifact_name }}'
|
|
||||||
Get-ChildItem
|
|
||||||
|
|
||||||
- name: Rename artifact (Unix)
|
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
|
run: chmod +x dist/${{ env.APP_NAME }}
|
||||||
|
|
||||||
|
- name: Rename artifact
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
chmod +x ${{ env.APP_NAME }}
|
mv ${{ env.APP_NAME }}${{ runner.os == 'Windows' && '.exe' || '' }} ${{ matrix.artifact_name }}
|
||||||
mv ${{ env.APP_NAME }} ${{ matrix.artifact_name }}
|
|
||||||
ls -la
|
ls -la
|
||||||
|
|
||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
@@ -163,7 +157,7 @@ jobs:
|
|||||||
mkdir -p release
|
mkdir -p release
|
||||||
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
||||||
cp artifacts/ubuntu-22.04-build/SoftwareManager-dev-*-linux release/SoftwareManager-dev-${SHORT_SHA}-linux
|
cp artifacts/ubuntu-22.04-build/SoftwareManager-dev-*-linux release/SoftwareManager-dev-${SHORT_SHA}-linux
|
||||||
cp artifacts/windows-latest-build/SoftwareManager-dev-*-windows.zip release/SoftwareManager-dev-${SHORT_SHA}-windows.zip
|
cp artifacts/windows-latest-build/SoftwareManager-dev-*-windows.exe release/SoftwareManager-dev-${SHORT_SHA}-windows.exe
|
||||||
cp artifacts/macos-latest-build/SoftwareManager-dev-*-macos release/SoftwareManager-dev-${SHORT_SHA}-macos
|
cp artifacts/macos-latest-build/SoftwareManager-dev-*-macos release/SoftwareManager-dev-${SHORT_SHA}-macos
|
||||||
chmod +x release/SoftwareManager-dev-*-linux release/SoftwareManager-dev-*-macos
|
chmod +x release/SoftwareManager-dev-*-linux release/SoftwareManager-dev-*-macos
|
||||||
ls -la release/
|
ls -la release/
|
||||||
@@ -181,7 +175,7 @@ jobs:
|
|||||||
|
|
||||||
### Downloads
|
### Downloads
|
||||||
- Linux: \`SoftwareManager-dev-${SHORT_SHA}-linux\`
|
- Linux: \`SoftwareManager-dev-${SHORT_SHA}-linux\`
|
||||||
- Windows: \`SoftwareManager-dev-${SHORT_SHA}-windows.zip\`
|
- Windows: \`SoftwareManager-dev-${SHORT_SHA}-windows.exe\`
|
||||||
- macOS: \`SoftwareManager-dev-${SHORT_SHA}-macos\`
|
- macOS: \`SoftwareManager-dev-${SHORT_SHA}-macos\`
|
||||||
EOF
|
EOF
|
||||||
cat release_notes.md
|
cat release_notes.md
|
||||||
@@ -194,7 +188,7 @@ jobs:
|
|||||||
body_path: release_notes.md
|
body_path: release_notes.md
|
||||||
files: |
|
files: |
|
||||||
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-linux
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-linux
|
||||||
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-windows.zip
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-windows.exe
|
||||||
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-macos
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-macos
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
+125
-28
@@ -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
|
||||||
@@ -134,18 +134,18 @@ 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()
|
||||||
@@ -154,22 +154,22 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
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()
|
||||||
@@ -273,13 +273,14 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
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:
|
||||||
@@ -328,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())
|
||||||
@@ -338,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
|
||||||
|
|
||||||
@@ -377,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):
|
||||||
@@ -405,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)
|
||||||
|
|
||||||
@@ -417,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)
|
||||||
@@ -463,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:
|
||||||
@@ -519,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)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
from core.utils.general.logs import consoleLog
|
||||||
|
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}]")
|
||||||
|
|
||||||
@@ -7,6 +7,3 @@ def add_magnet(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}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ 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
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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
|
||||||
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
|
||||||
@@ -28,7 +29,7 @@ def run_gui():
|
|||||||
|
|
||||||
if state.window_transparency and platform.system() != "Windows":
|
if state.window_transparency and platform.system() != "Windows":
|
||||||
widget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
widget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
widget.setStyleSheet("MainWindow { background: transparent; }")
|
qdarktheme.setup_theme("auto", custom_colors={"background": "#00000000"})
|
||||||
|
|
||||||
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)
|
||||||
@@ -51,6 +52,8 @@ if __name__ == "__main__":
|
|||||||
consoleLog("Started update_log thread")
|
consoleLog("Started update_log thread")
|
||||||
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
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("Launching GUI")
|
consoleLog("Launching GUI")
|
||||||
run_gui()
|
run_gui()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import psutil
|
||||||
|
|
||||||
|
addrs = psutil.net_if_addrs()
|
||||||
|
stats = psutil.net_if_stats()
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
print(f'"{interface}": True')
|
||||||
|
active.append(interface)
|
||||||
|
print(active)
|
||||||
|
return active
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
get_active_interfaces()
|
||||||
|
|
||||||
|
# print(addrs)
|
||||||
|
# print()
|
||||||
|
# sigmer = list()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# for interface in stats.keys():
|
||||||
|
# print(f"{interface}: UP = {stats[interface].isup}")
|
||||||
|
# sigmer.append(f"{interface}: {stats[interface].isup}")
|
||||||
|
|
||||||
|
# print(sigmer)
|
||||||
Reference in New Issue
Block a user