Skip to content

Commit

Permalink
add option to not move converted files to external folder
Browse files Browse the repository at this point in the history
  • Loading branch information
zaytiri committed Oct 9, 2024
1 parent 5ddb86f commit 31a052e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
8 changes: 8 additions & 0 deletions havc/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def __add_arguments(self):
help=self.prog_arguments.shutdown_when_done.help_message,
default=self.prog_arguments.shutdown_when_done.default,
metavar=self.prog_arguments.shutdown_when_done.metavar)

self.args.add_argument(self.prog_arguments.is_deleted_enabled.full_name,
action=argparse.BooleanOptionalAction,
required=False,
help=self.prog_arguments.is_deleted_enabled.help_message,
default=self.prog_arguments.is_deleted_enabled.default,
metavar=self.prog_arguments.is_deleted_enabled.metavar)


def __check_any_errors(self):
if self.__target_and_original_extensions_are_the_same():
Expand Down
12 changes: 11 additions & 1 deletion havc/entities/prog_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def __init__(self):
'True: --shutdown | False: --no-shutdown',
"",
default=False)

self.is_deleted_enabled = Argument('enable_delete',
'',
'--enable-delete',
'enable/disable if files will be moved to a external folder: (default is enabled). if disabled the original files will remain in the same folder as the converted files.'
'True: --enable-delete | False: --no-enable-delete',
"",
default=True)

def to_list(self):
arguments = [
Expand All @@ -82,7 +90,8 @@ def to_list(self):
self.deleted_folder,
self.custom_command,
self.safety_question,
self.shutdown_when_done
self.shutdown_when_done,
self.is_deleted_enabled
]
return arguments

Expand All @@ -95,3 +104,4 @@ def from_list(self, arguments):
self.custom_command = arguments[5]
self.safety_question = arguments[6]
self.shutdown_when_done = arguments[7]
self.is_deleted_enabled = arguments[8]
14 changes: 9 additions & 5 deletions havc/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ def __init__(self, arguments):
self.original_file_extensions = arguments.original_extensions.value
self.target_file_extension = arguments.target_extension.value
self.delete_folder = arguments.deleted_folder.value
self.is_deleted_enabled = arguments.is_deleted_enabled.value
self.custom_command = arguments.custom_command.value

def search(self):
main_directory = Directory(self.folder_path)
output_file = Output()
found_files = False

delete_folder = self.create_delete_folder()
if self.is_deleted_enabled:
delete_folder = self.create_delete_folder()

for root, dirs, files in main_directory.search_through():
if self.delete_folder in root:
Expand Down Expand Up @@ -50,12 +52,14 @@ def search(self):
continue

print('\nEncoding successfully done!\n\n')
sub_delete_folder = self.create_delete_sub_folder(root, delete_folder)


converted_video_file_path = current_video_file.absolute_path + self.target_file_extension
current_video_file.copy_metadata_to(converted_video_file_path)

current_video_file.copy_to(sub_delete_folder)

if self.is_deleted_enabled:
sub_delete_folder = self.create_delete_sub_folder(root, delete_folder)
current_video_file.copy_to(sub_delete_folder)

output_file.add_file(current_video_file)

if found_files:
Expand Down

0 comments on commit 31a052e

Please sign in to comment.