from PySide6.QtCore import Signal, QThread class VideoDownloader(QThread): # Signal for the window to establish the maximum value # of the progress bar. setTotalProgress = Signal(int) # Signal to increase the progress. setCurrentProgress = Signal(int) # Signal to be emitted when the file has been downloaded successfully. succeeded = Signal() def __init__(self, kontor_db, log): super().__init__() self.kontor_db = kontor_db self.log = log def run(self): self.log.info("download videos for table MediaFile") download_entries = self.kontor_db.get_download_list() self.setTotalProgress.emit(len(download_entries)) for index, entry in enumerate(download_entries): self.kontor_db.download_file(entry) self.setCurrentProgress.emit(index) self.succeeded.emit()