-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
172 lines (152 loc) · 5.1 KB
/
config.py
File metadata and controls
172 lines (152 loc) · 5.1 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import argparse
def parse_args():
parser = argparse.ArgumentParser(description="Application configuration")
parser.add_argument("path", help="Path to media file/folder", default="/media")
parser.add_argument(
"--log-level", help="Logging level (default: INFO)", default="INFO"
)
parser.add_argument(
"--log-file", help="Path to log file (default: None)", default=None
)
parser.add_argument(
"--app-watch",
action="store_true",
default=False,
help="Enable app watch mode (default: false)",
)
parser.add_argument(
"--app-scan-interval",
type=int,
default=0,
help="App scan interval in mins (default: 0), 0=disabled",
)
parser.add_argument(
"--app-scan-timings",
nargs="+",
default=[],
help="Timing(s) in HH:MM (i.e. 13:33) to trigger the scans",
)
parser.add_argument(
"--app-enabled-extractor",
action="store_true",
default=True,
help="Enable extractor (default: true)",
)
parser.add_argument(
"--no-app-enabled-extractor",
dest="app_enabled_extractor",
action="store_false",
help="Disable extractor",
)
parser.add_argument(
"--app-enabled-postprocessor",
action="store_true",
default=True,
help="Enable postprocessor (default: true)",
)
parser.add_argument(
"--no-app-enabled-postprocessor",
dest="app_enabled_postprocessor",
action="store_false",
help="Disable postprocessor",
)
# Extractor settings
parser.add_argument(
"--extractor-exclude-enable",
action="store_true",
default=False,
help="Enable extractor exclude (default: false)",
)
parser.add_argument(
"--extractor-exclude-file",
type=str,
default="./extracted.txt",
help="Extractor exclude file path (default: ./extracted.txt)",
)
parser.add_argument(
"--extractor-exclude-append",
action="store_true",
default=False,
help="Append to extractor exclude file (default: false)",
)
parser.add_argument(
"--extractor-extract-bitmap",
action="store_true",
default=False,
help="Extract bitmap (default: false)",
)
parser.add_argument(
"--extractor-config-overwrite",
action="store_true",
default=False,
help="Overwrite existing subtitle file during extraction (default: False)",
)
parser.add_argument(
"--extractor-config-desired-formats",
nargs="+",
default=["srt", "ass"],
help="List of desired formats (default: srt ass)",
)
parser.add_argument(
"--extractor-config-languages",
nargs="+",
default=["all"],
help="List of languages (default: all)",
)
parser.add_argument(
"--extractor-config-unknown-language-as",
type=str,
default="eng",
help="Unknown language fallback (default: eng)",
)
# Postprocessor settings
parser.add_argument(
"--postprocessor-exclude-enable",
action="store_true",
default=False,
help="Postprocessor exclude enable (default: False)",
)
parser.add_argument(
"--postprocessor-exclude-file",
type=str,
default="./postprocessed.txt",
help="Postprocessor exclude file path (default: ./postprocessed.txt)",
)
parser.add_argument(
"--postprocessor-exclude-append",
action="store_true",
default=False,
help="Append to postprocessor exclude file (default: false)",
)
parser.add_argument(
"--postprocessor-config-workflow-file",
type=str,
default="postprocess.yaml",
help="Postprocessor workflow file (default: postprocess.yaml)",
)
args = parser.parse_args()
return args
config = parse_args()
PATH = config.path
LOG_LEVEL = config.log_level
LOG_FILE = config.log_file
APP_WATCH = config.app_watch
APP_SCAN_INTERVAL = config.app_scan_interval
APP_ENABLED_EXTRACTOR = config.app_enabled_extractor
APP_ENABLED_POSTPROCESSOR = config.app_enabled_postprocessor
APP_SCAN_TIMINGS: list[tuple[int, int]] = []
for time in config.app_scan_timings:
hour, mins = time.split(":")
APP_SCAN_TIMINGS.append((int(hour), int(mins)))
EXTRACTOR_EXCLUDE_ENABLE = config.extractor_exclude_enable
EXTRACTOR_EXCLUDE_FILE = config.extractor_exclude_file
EXTRACTOR_EXCLUDE_APPEND = config.extractor_exclude_append
EXTRACTOR_EXTRACT_BITMAP = config.extractor_extract_bitmap
EXTRACTOR_CONFIG_OVERWRITE = config.extractor_config_overwrite
EXTRACTOR_CONFIG_DESIRED_FORMATS = config.extractor_config_desired_formats
EXTRACTOR_CONFIG_LANGUAGES = config.extractor_config_languages
EXTRACTOR_CONFIG_UNKNOWN_LANGUAGE_AS = config.extractor_config_unknown_language_as
POSTPROCESSOR_EXCLUDE_ENABLE = config.postprocessor_exclude_enable
POSTPROCESSOR_EXCLUDE_FILE = config.postprocessor_exclude_file
POSTPROCESSOR_EXCLUDE_APPEND = config.postprocessor_exclude_append
POSTPROCESSOR_CONFIG_WORKFLOW_FILE = config.postprocessor_config_workflow_file