Added user-defined output directory
This commit is contained in:
parent
9b58cacaf3
commit
c5faaf242b
@ -20,10 +20,7 @@ def fetch_ini():
|
||||
with urllib.request.urlopen(config_url) as config_template:
|
||||
config_template = config_template.read().decode("utf-8")
|
||||
file.write(config_template)
|
||||
tk.messagebox.showinfo(
|
||||
"Reset config file",
|
||||
f"Config file has been reset"
|
||||
)
|
||||
tk.messagebox.showinfo("Reset config file", f"Config file has been reset")
|
||||
debug('DEBUG', f"Config file was reset to default")
|
||||
INVALID_INI = False
|
||||
except:
|
||||
@ -56,7 +53,8 @@ def checkinifile():
|
||||
'save_output': bool,
|
||||
'show_playback': bool,
|
||||
'roi_size': int,
|
||||
'window_size': str
|
||||
'window_size': str,
|
||||
'user_defined_output_dir': str
|
||||
}
|
||||
expected_debug_keys = {
|
||||
'debug_output': bool
|
||||
@ -147,4 +145,41 @@ def toggle_show():
|
||||
else:
|
||||
messagebox.showinfo("Info", "Video2Crops is currently processing files!")
|
||||
|
||||
# Function to create the output directory and return its path
|
||||
def create_output_directory(video_filename):
|
||||
debug('DEBUG', f"Creating output directory")
|
||||
base_directory = user_defined_output_dir
|
||||
video_filename_base, _ = os.path.splitext(os.path.basename(video_filename))
|
||||
output_folder_path = os.path.join(base_directory, video_filename_base)
|
||||
|
||||
# Create the output directory if it doesn't exist
|
||||
if not os.path.exists(output_folder_path):
|
||||
os.makedirs(output_folder_path)
|
||||
|
||||
debug('DEBUG', f"Processing file: {video_filename}")
|
||||
debug('DEBUG', f"Created output directory at: {output_folder_path}")
|
||||
return output_folder_path
|
||||
|
||||
def truncate_path(path, pre_max=None, post_max=None):
|
||||
# Split the path into components
|
||||
path_components = os.path.normpath(path).split(os.path.sep)
|
||||
|
||||
# Ensure the first two components are displayed in full
|
||||
pre_part = os.path.sep.join(path_components[:2])
|
||||
|
||||
# Ensure the last two components are displayed in full
|
||||
post_part = os.path.sep.join(path_components[-2:])
|
||||
|
||||
# Truncate the pre-portion if pre_max is specified
|
||||
if pre_max is not None:
|
||||
pre_part = pre_part[:pre_max]
|
||||
|
||||
# Truncate the post-portion if post_max is specified
|
||||
if post_max is not None:
|
||||
post_part = post_part[-post_max:]
|
||||
|
||||
# Combine the parts with ellipsis in between
|
||||
truncated_path = f"{pre_part}...{post_part}"
|
||||
|
||||
debug('DEBUG', f"Truncated the path \'{path}\' to \'{truncated_path}\'")
|
||||
return truncated_path
|
||||
|
Loading…
Reference in New Issue
Block a user