def queue_startup_check(self): new_queue = get_queue(self.app.fastflix.queue_path, self.app.fastflix.config) # self.app.fastflix.queue.append(item) reset_vids = [] remove_vids = [] for i, video in enumerate(new_queue): if video.status.running: reset_vids.append(i) if video.status.complete: remove_vids.append(video) for index in reset_vids: vid: Video = new_queue.pop(index) vid.status.clear() new_queue.insert(index, vid) for video in remove_vids: new_queue.remove(video) if new_queue: if yes_no_message( f"{t('Not all items in the queue were completed')}\n" f"{t('Would you like to keep them in the queue?')}", title="Recover Queue Items", ): with self.app.fastflix.queue_lock: for item in new_queue: self.app.fastflix.queue.append(item) # self.app.fastflix.queue = [] with self.app.fastflix.queue_lock: save_queue(self.app.fastflix.queue, self.app.fastflix.queue_path, self.app.fastflix.config) self.new_source()
def queue_startup_check(self, queue_file=None): new_queue = get_queue(queue_file or self.app.fastflix.queue_path) remove_vids = [] for i, video in enumerate(new_queue): if video.status.complete: remove_vids.append(video) else: video.status.clear() for video in remove_vids: new_queue.remove(video) if queue_file: self.app.fastflix.conversion_list = new_queue elif new_queue: if yes_no_message( f"{t('Not all items in the queue were completed')}\n" f"{t('Would you like to keep them in the queue?')}", title="Recover Queue Items", ): self.app.fastflix.conversion_list = new_queue self.new_source() save_queue(self.app.fastflix.conversion_list, self.app.fastflix.queue_path, self.app.fastflix.config)
def select_folder(self): if self.concat_area.table.model.rowCount() > 0: if not yes_no_message( f"{t('There are already items in this list')},\n" f"{t('if you open a new directory, they will all be removed.')}\n\n" f"{t('Continue')}?", "Confirm Change Folder", ): return folder_name = QtWidgets.QFileDialog.getExistingDirectory(self, dir=self.folder_name) if not folder_name: return self.folder_name = folder_name self.set_folder_name(folder_name) def check_to_add(file, list_of_items, bad_items, **_): try: data = None details = probe(self.app, file) for stream in details.streams: if stream.codec_type == "video": data = (file.name, f"{stream.width}x{stream.height}", stream.codec_name) if not data: raise Exception() except Exception: logger.warning(f"Skipping {file.name} as it is not a video/image file") bad_items.append(file.name) else: list_of_items.append(data) items = [] skipped = [] tasks = [] for file in Path(folder_name).glob("*"): if file.is_file(): tasks.append( Task( f"Evaluating {file.name}", command=check_to_add, kwargs={"file": file, "list_of_items": items, "bad_items": skipped}, ) ) ProgressBar(self.app, tasks, can_cancel=True, auto_run=True) self.concat_area.table.update_items(items) if skipped: error_message( "".join( [ f"{t('The following items were excluded as they could not be identified as image or video files')}:\n", "\n".join(skipped[:20]), f"\n\n+ {len(skipped[20:])} {t('more')}..." if len(skipped) > 20 else "", ] ) )
def manually_load_queue(self): filename = QtWidgets.QFileDialog.getOpenFileName( self, caption=t("Load Queue"), dir=os.path.expanduser("~"), filter=f"FastFlix Queue File (*.yaml)") if filename and filename[0]: is_yes = True if self.app.fastflix.conversion_list: is_yes = yes_no_message( (t("This will remove all items in the queue currently") + "\n" + t(f"It will update it with the contents of") + f":\n\n {filename[0]}\n\n" + t("Are you sure you want to proceed?")), title="Overwrite existing queue?", ) filename = Path(filename[0]) if not filename.exists(): error_message(t("That file doesn't exist")) if is_yes: self.queue_startup_check(filename)
def pause_resume_encode(self): if self.encode_paused: allow_sleep_mode() self.pause_encode.setText(t("Pause Encode")) self.pause_encode.setIcon(self.app.style().standardIcon( QtWidgets.QStyle.SP_MediaPause)) self.app.fastflix.worker_queue.put(["resume encode"]) else: if not yes_no_message( t("WARNING: This feature is not provided by the encoder software directly" ) + "<br><br>" + t("It is NOT supported by VCE or NVENC encoders, it will break the encoding" ) + "<br><br>" + t("Are you sure you want to continue?"), "Pause Warning", ): return prevent_sleep_mode() self.pause_encode.setText(t("Resume Encode")) self.pause_encode.setIcon(self.app.style().standardIcon( QtWidgets.QStyle.SP_MediaPlay)) self.app.fastflix.worker_queue.put(["pause encode"]) self.encode_paused = not self.encode_paused
def select_folder(self): if self.concat_area.table.model.rowCount() > 0: if not yes_no_message( f"{t('There are already items in this list')},\n" f"{t('if you open a new directory, they will all be removed.')}\n\n" f"{t('Continue')}?", "Confirm Change Folder", ): return folder_name = QtWidgets.QFileDialog.getExistingDirectory( self, dir=self.folder_name) if not folder_name: return self.folder_name = folder_name self.set_folder_name(folder_name) items = [] skipped = [] for file in Path(folder_name).glob("*"): if file.is_file(): try: details = self.get_video_details(file) if not details: raise Exception() except Exception: logger.warning( f"Skipping {file.name} as it is not a video/image file" ) skipped.append(file.name) else: items.append(details) self.concat_area.table.update_items(items) if skipped: error_message("".join([ f"{t('The following items were excluded as they could not be identified as image or video files')}:\n", "\n".join(skipped[:20]), f"\n\n+ {len(skipped[20:])} {t('more')}..." if len(skipped) > 20 else "", ]))