Fixing pep8 recomendations
This commit is contained in:
62
TVEncoder.py
62
TVEncoder.py
@@ -12,49 +12,52 @@ from libsettings import Settings
|
|||||||
from libhandbrake import Encoder
|
from libhandbrake import Encoder
|
||||||
from libtvdatasource import TVData
|
from libtvdatasource import TVData
|
||||||
|
|
||||||
#TVRECORDINGSDIR = "/Volumes/TV Recordings/"
|
|
||||||
#TVRECORDINGSDIR = "/srv/storage2/videos/TVRecordings/" # TODO move this to settings
|
|
||||||
|
|
||||||
def ShowHelp():
|
def ShowHelp():
|
||||||
print 'TVEncoder.py -p -n <number of files to prepare for processing> - prepare n recordings'
|
print 'TVEncoder.py -p -n <number of files to prepare for processing> ' \
|
||||||
print 'TVEncoder.py -p -l -n <number of files to process> - lists the files that will be processed without actually encoding them'
|
'- prepare n recordings'
|
||||||
|
print 'TVEncoder.py -p -l -n <number of files to process> - lists the ' \
|
||||||
|
'files that will be processed without actually encoding them'
|
||||||
print 'TVEncoder.py -e - encode the files that have been processed'
|
print 'TVEncoder.py -e - encode the files that have been processed'
|
||||||
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 PrintShowsToEncode(showsData):
|
def PrintShowsToEncode(showsData):
|
||||||
# print "/n".join(showData)
|
# print "/n".join(showData)
|
||||||
for showData in showsData:
|
for showData in showsData:
|
||||||
print showData.ToString()
|
print showData.ToString()
|
||||||
|
|
||||||
|
|
||||||
def PrintShowsToPrepare(showsData):
|
def PrintShowsToPrepare(showsData):
|
||||||
for showData in showsData:
|
for showData in showsData:
|
||||||
showData.Print()
|
showData.Print()
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
numFiles = 0
|
numFiles = 0
|
||||||
doEncode = False
|
doEncode = False
|
||||||
readOnly = False
|
readOnly = False
|
||||||
doList = False
|
doList = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,"hlpen:")
|
opts, args = getopt.getopt(argv, "hlpen:")
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
ShowHelp()
|
ShowHelp()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
ShowHelp()
|
ShowHelp()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif opt == "-p":
|
elif opt == "-p":
|
||||||
doEncode = False
|
doEncode = False
|
||||||
elif opt == "-e":
|
elif opt == "-e":
|
||||||
doEncode = True
|
doEncode = True
|
||||||
elif opt == "-n":
|
elif opt == "-n":
|
||||||
numFiles = arg
|
numFiles = arg
|
||||||
elif opt == "-l":
|
elif opt == "-l":
|
||||||
readOnly = True
|
readOnly = True
|
||||||
doList = True
|
doList = True
|
||||||
|
|
||||||
settings = Settings("settings.cfg")
|
settings = Settings("settings.cfg")
|
||||||
|
|
||||||
if readOnly and doList:
|
if readOnly and doList:
|
||||||
@@ -65,10 +68,6 @@ def main(argv):
|
|||||||
PrintShowsToEncode(showData)
|
PrintShowsToEncode(showData)
|
||||||
else:
|
else:
|
||||||
# Generate the list of files to process
|
# Generate the list of files to process
|
||||||
# tempShowList = ["Thomas and Friends", "Thomas the Tank Engine & Friends",
|
|
||||||
# "Chuggington", "Mike the Knight", "Octonauts",
|
|
||||||
# "The Octonauts", "In the Night Garden",
|
|
||||||
# "Raa Raa! The Noisy Lion"] # TODO get from settings
|
|
||||||
fileManager = FileManager(settings)
|
fileManager = FileManager(settings)
|
||||||
shows = fileManager.GetFilesToPrepare(numFiles)
|
shows = fileManager.GetFilesToPrepare(numFiles)
|
||||||
print "num results: {0}".format(len(shows))
|
print "num results: {0}".format(len(shows))
|
||||||
@@ -78,21 +77,24 @@ def main(argv):
|
|||||||
#Encode the files and move them to their final destination
|
#Encode the files and move them to their final destination
|
||||||
fileManager = FileManager(settings)
|
fileManager = FileManager(settings)
|
||||||
showData = fileManager.GetEncodingFiles(readOnly)
|
showData = fileManager.GetEncodingFiles(readOnly)
|
||||||
|
|
||||||
for show in showData:
|
for show in showData:
|
||||||
if fileManager.CheckFileExists(show.outputFile):
|
if fileManager.CheckFileExists(show.outputFile):
|
||||||
print "File {0} already exists. Cannot process.".format(show.outputFile)
|
print "File {0} already exists. Cannot process." \
|
||||||
|
.format(show.outputFile)
|
||||||
else:
|
else:
|
||||||
encoder = Encoder(settings.HandbrakeCommand())
|
encoder = Encoder(settings.HandbrakeCommand())
|
||||||
result = encoder.Encode(show.inputFile, show.outputFile)
|
result = encoder.Encode(show.inputFile, show.outputFile)
|
||||||
|
|
||||||
fileManager.PerformPostEncodeFileOperations(show.inputFile, show.outputFile)
|
fileManager.PerformPostEncodeFileOperations(
|
||||||
|
show.inputFile, show.outputFile)
|
||||||
else:
|
else:
|
||||||
# TODO Process files for encoding
|
# TODO Process files for encoding
|
||||||
fileManager = FileManager(settings)
|
fileManager = FileManager(settings)
|
||||||
shows = fileManager.GetFilesToPrepare(numFiles)
|
shows = fileManager.GetFilesToPrepare(numFiles)
|
||||||
tvData = TVData(settings)
|
tvData = TVData(settings)
|
||||||
tvData.PrepareEpisodes(shows)
|
tvData.PrepareEpisodes(shows)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|||||||
Reference in New Issue
Block a user