Av1an/Startup/file_validation.py

24 lines
529 B
Python
Raw Normal View History

2020-11-20 10:29:27 +00:00
#!/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