Put transcoding of episode into separate function
This commit is contained in:
parent
cd0deafe15
commit
cd71ca64b4
@ -196,33 +196,44 @@ def transcode_series(dvd: Dvd):
|
||||
episode = episodes[i]
|
||||
title_number = title_numbers[i]
|
||||
|
||||
episode_title = dvd.series_create_episode_title(season, episode)
|
||||
if episode_title is None:
|
||||
dvd.append_line_to_logfile(f"Dvd has non valid series name!! ({dvd})")
|
||||
output_file = transcode_episode(dvd, season, episode, title_number)
|
||||
if not output_file:
|
||||
return False
|
||||
|
||||
video_file_name = episode_title + OUT_VIDEO_FORMAT
|
||||
output_file = os.path.join(TMP_DIR, video_file_name)
|
||||
output_files.append(output_file)
|
||||
|
||||
with open(dvd.log_file, "w") as log_file:
|
||||
proc = subprocess.run(
|
||||
dvd.transcode_command_args_without_title_number(output_file)
|
||||
+ [
|
||||
"--title",
|
||||
str(title_number),
|
||||
"--min-duration",
|
||||
str(MIN_EPISODES_DURATION_SECONDS),
|
||||
],
|
||||
stderr=subprocess.STDOUT,
|
||||
stdout=log_file,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
return False
|
||||
else:
|
||||
output_files.append(output_file)
|
||||
|
||||
return output_files
|
||||
|
||||
|
||||
def transcode_episode(dvd: Dvd, season, episode, title_number):
|
||||
episode_title = dvd.series_create_episode_title(season, episode)
|
||||
if episode_title is None:
|
||||
dvd.append_line_to_logfile(f"Dvd has non valid series name!! ({dvd})")
|
||||
return False
|
||||
|
||||
print(f"Transcoding episode {episode_title}...")
|
||||
|
||||
video_file_name = episode_title + OUT_VIDEO_FORMAT
|
||||
output_file = os.path.join(TMP_DIR, video_file_name)
|
||||
|
||||
with open(dvd.log_file, "w") as log_file:
|
||||
proc = subprocess.run(
|
||||
dvd.transcode_command_args_without_title_number(output_file)
|
||||
+ [
|
||||
"--title",
|
||||
str(title_number),
|
||||
"--min-duration",
|
||||
str(MIN_EPISODES_DURATION_SECONDS),
|
||||
],
|
||||
stderr=subprocess.STDOUT,
|
||||
stdout=log_file,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
return False
|
||||
|
||||
return output_file
|
||||
|
||||
|
||||
def find_series_titles(dvd: Dvd):
|
||||
with open(dvd.log_file, "w") as log_file:
|
||||
proc = subprocess.run(
|
||||
|
Loading…
x
Reference in New Issue
Block a user