Added a check for existing files

This commit is contained in:
2013-07-13 11:55:36 +10:00
parent 22b94e372c
commit 3c2d87e6de

View File

@@ -12,6 +12,7 @@ from libsettings import Settings
import libhandbrake import libhandbrake
from libtvdatasource import TVData from libtvdatasource import TVData
from collections import namedtuple from collections import namedtuple
from termcolor import colored
def showhelp(): def showhelp():
@@ -27,12 +28,16 @@ def showhelp():
print 'TVEncoder.py -e -l - list the files that would be encoded' 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. Prints he details of the shows.
""" """
for showdata in shows: for showdata in shows:
if filemanager.checkfileexists(showdata.outputfile):
print colored("File {0} already exists!".format(
showdata.outputfile), 'red')
print showdata print showdata
@@ -81,12 +86,12 @@ def main(argv):
if inputoptions.doencode: if inputoptions.doencode:
#Generate the list of files that would be encoded #Generate the list of files that would be encoded
showdata = filemanager.getencodingfiles(inputoptions.readonly) showdata = filemanager.getencodingfiles(inputoptions.readonly)
print_shows(showdata) print_shows(showdata, filemanager)
else: else:
# Generate the list of files to process # Generate the list of files to process
shows = filemanager.getfilestoprepare(inputoptions.numfiles) shows = filemanager.getfilestoprepare(inputoptions.numfiles)
print "num results: {0}".format(len(shows)) print "num results: {0}".format(len(shows))
print_shows(shows) print_shows(shows, filemanager)
else: else:
if inputoptions.doencode: if inputoptions.doencode:
#Encode the files and move them to their final destination #Encode the files and move them to their final destination