From 5ca6c3861ee7bbb091f71197c1042d80a2941ed9 Mon Sep 17 00:00:00 2001 From: Shane Frischkorn Date: Sun, 21 Jul 2013 22:23:14 +1000 Subject: [PATCH] added check for pre-existing video files --- TVEncoder.py | 5 +++++ libfilemanager.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/TVEncoder.py b/TVEncoder.py index 9411b15..a1c58ca 100644 --- a/TVEncoder.py +++ b/TVEncoder.py @@ -151,6 +151,11 @@ def main(argv): filemanager.performpostencodefileoperations( show.inputfile, show.outputfile) + if filemanager.checkduplicates(show.outputfile): + actionlogger.info("There is an existing video file" + "present for {0}" + .format(show.outputfile)) + generallogger.info("Processing finished.") generallogger.info("===========================" "=============\n\n") diff --git a/libfilemanager.py b/libfilemanager.py index 735b9f2..1171d5e 100644 --- a/libfilemanager.py +++ b/libfilemanager.py @@ -112,6 +112,24 @@ class FileManager: #will reach here if there were less than numberofFiles found return showstoprocess + def checkduplicates(self, filename): + """ + Check to see if there are any other video files existing for the + episode + """ + + dirname = os.path.dirname(filename) + filename = os.path.basename(filename)[:6] + + for dirpath, dirnames, filenames in os.walk(dirname): + for show in filenames: + extension = os.path.splitext(show)[1] + if (extension in [".avi", ".mpg", ".mpeg", "mp4"] and + show[:6] == filename): + return True + + return False + @staticmethod def checkfileexists(filename): """