mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
added progress bar
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import aria2p
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import time
|
||||
|
||||
def run_aria2p():
|
||||
global aria2
|
||||
|
||||
aria2 = aria2p.API(
|
||||
aria2p.Client(
|
||||
@@ -22,8 +23,6 @@ def set_threads(threads):
|
||||
t = threads
|
||||
|
||||
|
||||
|
||||
|
||||
def aria2server():
|
||||
downloads_dir = os.path.join("Library")
|
||||
|
||||
@@ -42,3 +41,15 @@ def aria2server():
|
||||
|
||||
aria2server = subprocess.Popen(cmd)
|
||||
return aria2server
|
||||
|
||||
def dlprogress():
|
||||
try:
|
||||
download2 = aria2.get_downloads()
|
||||
if download2:
|
||||
for download in download2:
|
||||
progress = download.progress_string(0)
|
||||
progress_int = int(progress.strip('%'))
|
||||
return progress_int
|
||||
return 0
|
||||
except:
|
||||
return 0
|
||||
|
||||
+19
-9
@@ -1,5 +1,5 @@
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtCore import Qt, QTimer
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
@@ -13,6 +13,7 @@ from PySide6.QtWidgets import (
|
||||
QComboBox,
|
||||
QSpinBox,
|
||||
QTabWidget,
|
||||
QProgressBar,
|
||||
)
|
||||
from PySide6.QtGui import QIcon, QAction
|
||||
import darkdetect
|
||||
@@ -22,7 +23,7 @@ from core.scraping.rutracker_scraper import scrape_rutracker
|
||||
from core.scraping.utils import get_magnet_link
|
||||
from core.downloading.download import start_client
|
||||
from core.downloading.download import add_magnet
|
||||
from core.downloading.aria2p_server import set_threads
|
||||
from core.downloading.aria2p_server import dlprogress, set_threads
|
||||
|
||||
|
||||
|
||||
@@ -38,8 +39,6 @@ def pass_aria(aria):
|
||||
global aria2process
|
||||
aria2process = aria
|
||||
|
||||
|
||||
|
||||
global tracker
|
||||
tracker = "rutracker" # default tracker
|
||||
|
||||
@@ -69,11 +68,13 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
self.searchbar.setPlaceholderText("Search for software...")
|
||||
self.searchbar.setClearButtonEnabled(True)
|
||||
self.searchbar.setMinimumHeight(30)
|
||||
|
||||
|
||||
self.searchbar.returnPressed.connect(lambda: self.run_thread(threading.Thread(target=self.return_pressed))) # Triggers scraping function thread on enter
|
||||
|
||||
self.dlbutton = QtWidgets.QPushButton("Download")
|
||||
self.softwareList = QListWidget()
|
||||
self.libraryList = QListWidget()
|
||||
self.emptyLabel = QLabel("No items in library.")
|
||||
self.progressbar = QProgressBar()
|
||||
|
||||
container = QWidget()
|
||||
containerLayout = QVBoxLayout()
|
||||
@@ -93,7 +94,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
self.tabs = QTabWidget()
|
||||
|
||||
self.tab1 = create_tab("Download", self.searchbar, self.softwareList, self.tabs)
|
||||
self.tab2 = create_tab("Library", self.searchbar, self.softwareList, self.tabs)
|
||||
self.tab2 = create_tab("Library", self.emptyLabel, self.libraryList, self.tabs)
|
||||
|
||||
containerLayout.addWidget(self.tabs)
|
||||
|
||||
@@ -119,14 +120,19 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
|
||||
toolbar.setMovable(False)
|
||||
|
||||
self.progressbar.setValue(0)
|
||||
containerLayout.addWidget(self.progressbar)
|
||||
|
||||
self.progress_timer = QTimer()
|
||||
self.progress_timer.timeout.connect(self.update_progress)
|
||||
self.progress_timer.start(1000)
|
||||
|
||||
def set_tracker(self, _):
|
||||
global tracker
|
||||
tracker = self.tracker_list.currentText()
|
||||
|
||||
def settings_dialog(self):
|
||||
|
||||
|
||||
|
||||
if debug:
|
||||
print("Settings dialog opened")
|
||||
dialog = QDialog(self)
|
||||
@@ -253,5 +259,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
start_client()
|
||||
add_magnet(selected_magnet)
|
||||
|
||||
def update_progress(self):
|
||||
progress = dlprogress()
|
||||
self.progressbar.setValue(progress)
|
||||
|
||||
def run_thread(self, thread):
|
||||
thread.start()
|
||||
|
||||
Reference in New Issue
Block a user