|
15 | 15 | TODO: |
16 | 16 | - convert all string paths into os.path objects |
17 | 17 | - allow comma-separated string for --preset, e.g. medium,slow,slower, map to list |
18 | | -- add --matrix option to create default, best, small, best+small variants |
19 | 18 | - add compression ratio / space saved to log + screen output |
20 | 19 | - ~~if presets.json does not exist, download from github~~ |
21 | 20 |
|
22 | 21 | """ |
23 | 22 |
|
24 | 23 | # Check for Python 3.8 (required for shlex usage) |
25 | 24 | if not (sys.version_info[0] >= 3 and sys.version_info[1] >= 8): |
26 | | - sys.exit("FATAL: Requires Python3.8 or newer.") |
| 25 | + sys.exit("FATAL: Requires Python3.8 or newer.\n") |
27 | 26 |
|
28 | 27 | class Session(): |
29 | 28 | class Settings: |
@@ -97,7 +96,7 @@ def validate(self): |
97 | 96 | def summarize(self): |
98 | 97 | """ Summarize transcode session before starting |
99 | 98 | """ |
100 | | - print("{date}: {source}:".format(date=str(datetime.now()), source=self.path["source"])) |
| 99 | + print("{date}: Starting transcode session for {source}:".format(date=str(datetime.now()), source=self.path["source"])) |
101 | 100 | pprint(vars(self)) |
102 | 101 | print() |
103 | 102 |
|
@@ -171,38 +170,39 @@ def cleanup(self): |
171 | 170 | else: |
172 | 171 | valid_arguments = True |
173 | 172 | if not valid_arguments: |
174 | | - sys.exit("Invalid command-line arguments.") |
| 173 | + sys.exit("Invalid command-line arguments.\n") |
175 | 174 | elif args.all and args.quality: |
176 | 175 | print("Warning! Combining --all and --quality options is not recommended and may not produce optimal HEVC transcodes.") |
177 | 176 | while "need response": |
178 | 177 | reply = str(input("Proceed? (y/n) cccccccccc" )).lower().strip() |
179 | 178 | if reply[0] == "y": |
180 | 179 | break |
181 | 180 | if reply[0] == "n": |
182 | | - sys.exit("Aborting invocation with --all and --quality options.") |
| 181 | + sys.exit("Aborting invocation with --all and --quality options.\n") |
183 | 182 |
|
184 | 183 | # Build list of source files and create directories if necessary |
185 | 184 | extensions = [".mp4", ".m4v", ".mov", ".mkv", ".mpg", ".mpeg", ".avi", ".wmv", ".flv", ".webm", ".ts"] |
| 185 | +print("\nBuilding source list...") |
186 | 186 | if args.all: |
187 | 187 | source_files = ["source/" + file for file in os.listdir("source") if os.path.splitext(file)[1].lower() in extensions] |
188 | 188 | else: |
189 | 189 | source_files = [args.file] |
190 | 190 | for source_file in source_files: |
191 | | - session = Session(source_file) |
192 | | - if os.path.exists(session.path["output"]): |
193 | | - print("Skipping", source_file) |
194 | | - source_files = [file for file in source_files if file is not source_file] |
195 | | - print(source_files) |
196 | | - if len(source_files) == 0: |
197 | | - sys.exit("All source files have already been transcoded. Exiting.") |
| 191 | + session = Session(source_file) |
| 192 | + if os.path.exists(session.path["output"]): |
| 193 | + print(" Skipping", source_file) |
| 194 | + source_files = [file for file in source_files if file is not source_file] |
| 195 | +if len(source_files) == 0: |
| 196 | + sys.exit("All source files have already been transcoded. Exiting.\n") |
| 197 | +else: |
| 198 | + print(str(source_files) + "\n") |
198 | 199 | if not os.path.exists("performance"): |
199 | 200 | os.mkdir("performance") |
200 | 201 | if not os.path.exists("hevc"): |
201 | 202 | os.mkdir("hevc") |
202 | 203 |
|
203 | 204 | # Do the thing |
204 | 205 | start_time = datetime.now() |
205 | | -print("\n{date}: Starting transcode session for {source_files}\n".format(date=str(datetime.now()), source_files=str(source_files))) |
206 | 206 | for file in source_files: |
207 | 207 | session = Session(file) |
208 | 208 | session.summarize() |
|
0 commit comments