From a7a80677f670c828e3f30347cffe24ab299a700a Mon Sep 17 00:00:00 2001 From: frarol96 Date: Wed, 11 Oct 2023 16:06:51 +0000 Subject: [PATCH] Added duplicate file check New duplicate file check prevents the queuing of duplicate files (by name/file path) --- Video2Crops.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Video2Crops.py b/Video2Crops.py index 7fca611..41504c8 100644 --- a/Video2Crops.py +++ b/Video2Crops.py @@ -395,11 +395,15 @@ def process_video(video_filenames, main_window): # Create a function to add files to the selected files Listbox def add_files(): + selected_files = selected_files_listbox.get(0, tk.END) file_paths = filedialog.askopenfilenames(filetypes=[("Video Files", "*.mp4 *.avi *.mov")]) if file_paths: for file_path in file_paths: - selected_files_listbox.insert(tk.END, file_path) - debug('DEBUG', f"Queued video file: {file_path}") + if file_path not in selected_files: + selected_files_listbox.insert(tk.END, file_path) + debug('DEBUG', f"Queued video file: {file_path}") + else: + debug('DEBUG', f"Attempted to queue already-queued file \'{file_path}\'") # Create a button to remove the selected file from the Listbox def remove_file(): @@ -430,7 +434,7 @@ def cancel_processing(): # Create a button to process the selected files def process_files(): debug('DEBUG', f"Starting file processing ...") - global processing, processing_thread + global processing, processing_thread, selected_files if not processing: processing = True selected_files = selected_files_listbox.get(0, tk.END) @@ -444,7 +448,7 @@ def process_files(): # Define dynamic process/cancel button def process_cancel_toggle(): debug('DEBUG', f"Toggling process/cancel button state") - global processing, processing_thread, processing_button_state + global processing, processing_thread, processing_button_state, selected_files if processing_button_state == "start": if not processing: processing = True @@ -632,7 +636,8 @@ label.pack(padx=20, pady=5) # Create a Listbox to display the selected files selected_files_listbox = tk.Listbox(root, selectmode=tk.SINGLE, exportselection=0) selected_files_listbox.pack(fill=tk.BOTH, expand=True, padx=20, pady=5) -DEBUG +selected_files = selected_files_listbox.get(0, tk.END) + # Create a button to select and add files to the Listbox select_files_button = tk.Button(root, text="Select Files", command=add_files) select_files_button.pack(padx=20, pady=5)