From 3c2d87e6de3b624b38067c042854a148fdc87454 Mon Sep 17 00:00:00 2001 From: Shane Frischkorn Date: Sat, 13 Jul 2013 11:55:36 +1000 Subject: [PATCH] Added a check for existing files --- TVEncoder.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/TVEncoder.py b/TVEncoder.py index d80a1a4..7dc2614 100644 --- a/TVEncoder.py +++ b/TVEncoder.py @@ -12,6 +12,7 @@ from libsettings import Settings import libhandbrake from libtvdatasource import TVData from collections import namedtuple +from termcolor import colored def showhelp(): @@ -27,12 +28,16 @@ def showhelp(): print 'TVEncoder.py -e -l - list the files that would be encoded' -def print_shows(shows): +def print_shows(shows, filemanager): """ Prints he details of the shows. """ for showdata in shows: + if filemanager.checkfileexists(showdata.outputfile): + print colored("File {0} already exists!".format( + showdata.outputfile), 'red') + print showdata @@ -81,12 +86,12 @@ def main(argv): if inputoptions.doencode: #Generate the list of files that would be encoded showdata = filemanager.getencodingfiles(inputoptions.readonly) - print_shows(showdata) + print_shows(showdata, filemanager) else: # Generate the list of files to process shows = filemanager.getfilestoprepare(inputoptions.numfiles) print "num results: {0}".format(len(shows)) - print_shows(shows) + print_shows(shows, filemanager) else: if inputoptions.doencode: #Encode the files and move them to their final destination