From d00f1513aca4d5519d3b1d58030fc2480075b526 Mon Sep 17 00:00:00 2001 From: sybilin <75937205+sybilin@users.noreply.github.com> Date: Sun, 13 Dec 2020 16:40:13 +0100 Subject: [PATCH] input: to be able to have several directories and files --- Startup/file_validation.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Startup/file_validation.py b/Startup/file_validation.py index 5e78a6e..3ba3559 100644 --- a/Startup/file_validation.py +++ b/Startup/file_validation.py @@ -8,16 +8,19 @@ def process_inputs(inputs): print('No input file') exit() - if inputs[0].is_dir(): - inputs = [x for x in inputs[0].iterdir() if x.suffix in (".mkv", ".mp4", ".mov", ".avi", ".flv", ".m2ts")] + input_list = [] - valid = np.array([i.exists() for i in inputs]) + for item in inputs: + if item.is_dir(): + new_inputs = [x for x in item.iterdir() if x.suffix in (".mkv", ".mp4", ".mov", ".avi", ".flv", ".m2ts")] + input_list.extend(new_inputs) + else: + input_list.append(item) + + valid = np.array([i.exists() for i in input_list]) if not all(valid): - print(f'File(s) do not exist: {", ".join([str(inputs[i]) for i in np.where(not valid)[0]])}') + print(f'File(s) do not exist: {", ".join([str(input_list[i]) for i in np.where(not valid)[0]])}') exit() - return inputs - - - + return input_list