diff --git a/.gitignore b/.gitignore index 25ba24c..25aab66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ rip.log ripped/ tmp/ +/transcoder/raw/ +/transcoder/transcode.log diff --git a/transcoder/transcode_dvd.py b/transcoder/transcode_dvd.py old mode 100644 new mode 100755 index c6b4dc5..05c5eef --- a/transcoder/transcode_dvd.py +++ b/transcoder/transcode_dvd.py @@ -21,15 +21,20 @@ def main(): mkdirs() for dvd_type in ("movie", "series"): for dvd in filter(is_dvd_files_not_locked, list_ripped_dvds(dvd_type)): + print(f"Transcoding {dvd_type} {dvd}") + # TOOD: nice transcoding process so it does not block server success = transcode_ripped_dvd(dvd, dvd_type) - dvd_title = "" # TODO + dvd_title = os.path.basename(dvd) if success: mv_video_from_tmp_to_transcoded_dir(dvd_title, dvd_type) write_to_logfile(dvd_type, dvd_title, "Success") delete_original_video_files(dvd) delete_transcoding_logfile(dvd) + print("Success") else: write_to_logfile(dvd_type, dvd_title, "FAILURE") + err_log_file = dvd + ".err.log" + print(f"Failed. Please see logs at {err_log_file}") delete_tmp_dir() @@ -52,6 +57,7 @@ def list_ripped_dvds(dvd_type): dvd_titles = os.listdir(path) 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) return map(lambda dvd_title: os.path.join(path, dvd_title), dvd_titles) except FileNotFoundError: print( @@ -61,7 +67,11 @@ def list_ripped_dvds(dvd_type): def is_dvd_files_not_locked(dvd): - return not os.path.exists(dvd + ".lock") and not os.path.exists(dvd + ".err.log") + return ( + not os.path.exists(dvd + ".lock") + and not os.path.exists(dvd + ".err.log") + and not os.path.exists(dvd + ".log") + ) def transcode_ripped_dvd(ripped_dvd, dvd_type): @@ -74,7 +84,7 @@ def transcode_ripped_dvd(ripped_dvd, dvd_type): def transcode_movie(movie): video_file_name = os.path.basename(movie) + OUT_VIDEO_FORMAT output_file = os.path.join(TMP_DIR, video_file_name) - log_file_path = movie + ".err.log" + log_file_path = movie + ".log" with open(log_file_path, "w") as log_file: @@ -122,7 +132,11 @@ def write_to_logfile(dvd_type, dvd_title, tag): def delete_transcoding_logfile(dvd): - os.remove(dvd + "err.log") + os.remove(dvd + ".log") + + +def rename_transcoding_logfile_as_error_log(dvd): + shutil.move(dvd + ".log", dvd + ".err.log") def delete_original_video_files(folder):