diff --git a/transcoder/transcode_dvd.py b/transcoder/transcode_dvd.py index 71416c4..791133d 100755 --- a/transcoder/transcode_dvd.py +++ b/transcoder/transcode_dvd.py @@ -56,6 +56,7 @@ class Dvd: self.log_file = dvd_path + ".log" self.err_log_file = dvd_path + ".err.log" + self.titles_file = dvd_path + ".titles" def __str__(self): return f"{self.dvd_type} {self.dvd_path}" @@ -138,6 +139,7 @@ def list_ripped_dvds(dvd_type): dvd_titles = filter(lambda title: not title.endswith(".lock"), dvd_titles) dvd_titles = filter(lambda title: not title.endswith(".err.log"), dvd_titles) dvd_titles = filter(lambda title: not title.endswith(".log"), dvd_titles) + dvd_titles = filter(lambda title: not title.endswith(".titles"), dvd_titles) return map( lambda dvd_title: Dvd(dvd_type, os.path.join(path, dvd_title)), dvd_titles ) @@ -245,6 +247,9 @@ def transcode_episode(dvd: Dvd, season, episode, title_number): def find_series_titles(dvd: Dvd): + if os.path.exists(dvd.titles_file): + return read_titles_from_titles_file(dvd) + with open(dvd.log_file, "w") as log_file: proc = subprocess.run( [ @@ -290,6 +295,22 @@ def find_series_titles(dvd: Dvd): return titles +def read_titles_from_titles_file(dvd: Dvd): + titles = [] + dvd.append_line_to_logfile("Found .titles file! Reading titles from there...") + try: + with open(dvd.titles_file, "r") as titles_file: + for line in titles_file.readlines(): + titles.append(int(line)) + except: + dvd.append_line_to_logfile( + "Failed reading titles file! Please make sure it has the right format" + ) + return [] + + return titles + + def is_json_title_duration_not_too_long(title): duration = title["Duration"] duration_seconds = duration["Hours"] * 60 * 60