Fix bugs, Add error messages

This commit is contained in:
2022-09-12 15:32:09 +02:00
parent e6917b9807
commit 140d30d767
3 changed files with 43 additions and 13 deletions

View File

@ -13,10 +13,12 @@ TRANSCODED_DIR = "transcoded"
LOGFILE = "transcode.log"
HANDBRAKE_PROCESS_NICE_LEVEL = 10
HANDBRAKE_PRESET = "General/HQ 1080p30 Surround"
HANDBRAKE_PRESET_MOVIE = "General/HQ 1080p30 Surround"
HANDBRAKE_PRESET_SERIES = "General/Fast 1080p30"
HANDBRAKE_AUDIO_LANG_LIST = "de,en"
OUT_VIDEO_FORMAT = ".m4v"
MIN_EPISODES_DURATION_SECONDS = 10 * 60
OUT_VIDEO_FORMAT = ".mkv"
MIN_EPISODES_DURATION_SECONDS = 30 * 60
MAX_EPISODES_DURATION_SECONDS = 1.5 * 60 * 60
SERIES_TITLE_REGEX = r"S(\d+)[ _]?E(\d+)-(\d+)$"
@ -90,13 +92,17 @@ class Dvd:
return (series, episodes)
def transcode_command_args_without_title_number(self, output_file):
handbrake_preset = HANDBRAKE_PRESET_MOVIE
if self.is_series():
handbrake_preset = HANDBRAKE_PRESET_SERIES
args = [
"nice",
"-n",
str(HANDBRAKE_PROCESS_NICE_LEVEL),
"HandBrakeCLI",
"--preset",
HANDBRAKE_PRESET,
handbrake_preset,
"--first-audio",
"--audio-lang-list",
HANDBRAKE_AUDIO_LANG_LIST,
@ -224,8 +230,8 @@ def transcode_episode(dvd: Dvd, season, episode, title_number):
+ [
"--title",
str(title_number),
"--min-duration",
str(MIN_EPISODES_DURATION_SECONDS),
# "--min-duration",
# str(MIN_EPISODES_DURATION_SECONDS),
],
stderr=subprocess.STDOUT,
stdout=log_file,
@ -274,10 +280,22 @@ def find_series_titles(dvd: Dvd):
break
json_obj = json.loads(json_str)
titles = list(map(lambda title: title["Index"], json_obj["TitleList"]))
titles = json_obj["TitleList"]
if dvd.is_series():
titles = filter(is_json_title_duration_not_too_long, titles)
titles = list(map(lambda title: title["Index"], titles))
return titles
def is_json_title_duration_not_too_long(title):
duration = title["Duration"]
duration_seconds = duration["Hours"] * 60 * 60
duration_seconds += duration["Minutes"] * 60
duration_seconds += duration["Seconds"]
return duration_seconds <= MAX_EPISODES_DURATION_SECONDS
def mv_videos_from_tmp_to_transcoded_dir(video_files, video_type):
for video_file in video_files:
src = video_file