Skip to content

Commit d4c9eaf

Browse files
committed
Improved stdout formatting
1 parent 54eae8e commit d4c9eaf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

transcode.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
TODO:
1616
- convert all string paths into os.path objects
1717
- 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
1918
- add compression ratio / space saved to log + screen output
2019
- ~~if presets.json does not exist, download from github~~
2120
2221
"""
2322

2423
# Check for Python 3.8 (required for shlex usage)
2524
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")
2726

2827
class Session():
2928
class Settings:
@@ -97,7 +96,7 @@ def validate(self):
9796
def summarize(self):
9897
""" Summarize transcode session before starting
9998
"""
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"]))
101100
pprint(vars(self))
102101
print()
103102

@@ -171,38 +170,39 @@ def cleanup(self):
171170
else:
172171
valid_arguments = True
173172
if not valid_arguments:
174-
sys.exit("Invalid command-line arguments.")
173+
sys.exit("Invalid command-line arguments.\n")
175174
elif args.all and args.quality:
176175
print("Warning! Combining --all and --quality options is not recommended and may not produce optimal HEVC transcodes.")
177176
while "need response":
178177
reply = str(input("Proceed? (y/n) cccccccccc" )).lower().strip()
179178
if reply[0] == "y":
180179
break
181180
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")
183182

184183
# Build list of source files and create directories if necessary
185184
extensions = [".mp4", ".m4v", ".mov", ".mkv", ".mpg", ".mpeg", ".avi", ".wmv", ".flv", ".webm", ".ts"]
185+
print("\nBuilding source list...")
186186
if args.all:
187187
source_files = ["source/" + file for file in os.listdir("source") if os.path.splitext(file)[1].lower() in extensions]
188188
else:
189189
source_files = [args.file]
190190
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")
198199
if not os.path.exists("performance"):
199200
os.mkdir("performance")
200201
if not os.path.exists("hevc"):
201202
os.mkdir("hevc")
202203

203204
# Do the thing
204205
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)))
206206
for file in source_files:
207207
session = Session(file)
208208
session.summarize()

0 commit comments

Comments
 (0)