-
Notifications
You must be signed in to change notification settings - Fork 18
/
arguments_validator.py
40 lines (30 loc) · 1.42 KB
/
arguments_validator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from utils import is_list
class ArgumentsValidator:
def validate(self, args):
validation_results = []
validation_errors = []
result = True
validation_results.append(self.__validate_original_video_exists(args.original_video_path))
validation_results.append(
self.__validate_crf_and_preset_count(args.no_transcoding_mode, args.crf, args.preset)
)
for validation_tuple in validation_results:
if not validation_tuple[0]:
result = False
validation_errors.append(validation_tuple[1])
return result, validation_errors
def __validate_original_video_exists(self, video_path):
return (os.path.exists(video_path), f"Unable to find {video_path}")
def __validate_crf_and_preset_count(self, no_transcoding_mode, crf_values, presets):
if not no_transcoding_mode and isinstance(crf_values, int) and isinstance(presets, str):
return (
False,
"No CRF value or preset has been specified. Did you mean to use the -ntm mode?",
)
elif is_list(crf_values) and len(crf_values) > 1 and is_list(presets) and len(presets) > 1:
return (
False,
"More than one CRF value AND more than one preset specified. No suitable mode found.",
)
return (True, "")