From 5eb7039c9406e9d7e225e5eb615b6385fa03fb5a Mon Sep 17 00:00:00 2001 From: Zen Date: Fri, 20 Nov 2020 12:29:27 +0200 Subject: [PATCH] Move file validation --- Startup/file_validation.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Startup/file_validation.py diff --git a/Startup/file_validation.py b/Startup/file_validation.py new file mode 100644 index 0000000..5e78a6e --- /dev/null +++ b/Startup/file_validation.py @@ -0,0 +1,23 @@ +#!/bin/env python +import numpy as np + + +def process_inputs(inputs): + # Check input file for being valid + if not 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")] + + valid = np.array([i.exists() for i in inputs]) + + if not all(valid): + print(f'File(s) do not exist: {", ".join([str(inputs[i]) for i in np.where(not valid)[0]])}') + exit() + + return inputs + + +