interim commit
This commit is contained in:
@@ -11,6 +11,8 @@ import libfilemanager
|
||||
import libsettings
|
||||
import libhandbrake
|
||||
|
||||
TVRECORDINGSDIR = "/srv/storage2/videos/TVRecordings/" # TODO move this to settings
|
||||
|
||||
def ShowHelp():
|
||||
print 'TVEncoder.py -p -n <number of files to prepare for processing> - 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'
|
||||
@@ -47,7 +49,7 @@ def main(argv):
|
||||
readOnly = True
|
||||
doList = True
|
||||
|
||||
shows = Settings("")
|
||||
shows = Settings("") # TODO call actual settings file
|
||||
|
||||
if readOnly and doList:
|
||||
if doEncode:
|
||||
@@ -56,6 +58,7 @@ def main(argv):
|
||||
PrintShowsToEncode(showData)
|
||||
else:
|
||||
# Generate the list of files to process
|
||||
files = GetFilesToPrepare(TVRECORDINGSDIR, numFiles, shows)
|
||||
else:
|
||||
if doEncode:
|
||||
#Encode the files and move them to their final destination
|
||||
@@ -69,7 +72,7 @@ def main(argv):
|
||||
|
||||
PerformPostEncodeFileOperations(show.inputFile, show.outputFile)
|
||||
else:
|
||||
#Process files for encoding
|
||||
# TODO Process files for encoding
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
@@ -5,6 +5,8 @@ Created on Fri Jul 5 14:11:31 2013
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import glob
|
||||
import libtvdatasource as TVData
|
||||
import os
|
||||
import shutil
|
||||
|
||||
@@ -16,8 +18,8 @@ class EncodeData:
|
||||
show = None
|
||||
outputFile = ''
|
||||
|
||||
def ToString():
|
||||
return "Input: {0}/tOutput: {2}".format(inputFile, outputFile)
|
||||
def ToString(self):
|
||||
return "Input: {0}/tOutput: {2}".format(self.inputFile, self.outputFile)
|
||||
|
||||
def __GetInputFilesToEncode(shows):
|
||||
fileList = []
|
||||
@@ -72,3 +74,23 @@ def PerformPostEncodeFileOperations(inputFileName, outputFileName):
|
||||
os.remove(linkAddress)
|
||||
|
||||
os.symlink(outputFileName, linkAddress)
|
||||
|
||||
def GetFilesToPrepare(path, numberofFiles, shows):
|
||||
files = glob.glob("{0}*.mpg".format(path))
|
||||
files = sorted(files, key=os.path.getctime)
|
||||
files = filter(lambda file: not os.path.islink(file), files)
|
||||
|
||||
#files is now a list of unprocessed files, but contains shows other than those we are interested in
|
||||
|
||||
filesToProcess = []
|
||||
i = 0
|
||||
for file in files:
|
||||
# TODO get these from settings
|
||||
if TVData.CheckTitleIsInList('localhost', 'script', 'script', 'mythconverg', file):
|
||||
filesToProcess.append(file)
|
||||
i = i + 1
|
||||
if i == numberofFiles:
|
||||
return filesToProcess
|
||||
|
||||
return filesToProcess #will reach here if there were less than numberofFiles found
|
||||
|
||||
@@ -5,10 +5,65 @@ Created on Fri Jul 5 14:42:47 2013
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import libmythtv as MythTV
|
||||
from libsickbeard import Sickbeard
|
||||
|
||||
class TVShow:
|
||||
def __init__(self, episode, season, title, subtitle, description):
|
||||
def __init__(self, episode, season, title, subtitle, description, inputFile='', outputFile=''):
|
||||
self.episode = episode
|
||||
self.season = season
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.description = description
|
||||
self.inputFile = inputFile
|
||||
self.outputFile = outputFile
|
||||
|
||||
def FixEpisodeSeasonNumber(number):
|
||||
if number < 10:
|
||||
return "0{0}".format(number)
|
||||
else:
|
||||
return str(number)
|
||||
|
||||
def RetrieveEpisodeData(serverAddress, user, password, database, inputFile, showsToProcess):
|
||||
show = MythTV.RetrieveEpisodeData('localhost', 'script', 'script', 'mythconverg', file)
|
||||
|
||||
if show.title:
|
||||
if show.subtitle:
|
||||
show.subtitle = GetEpisodeName(show.subtitle, show.title)
|
||||
|
||||
if (show.season == '0' or show.episode == '0'):
|
||||
showId = Sickbeard.FindShowId(show.title)
|
||||
|
||||
result = Sickbeard.FindEpisode(showId, show.subtitle, show.description)
|
||||
show.season = result[0]
|
||||
show.episode = result[1]
|
||||
|
||||
if show.season != "0" and show.episode != "0":
|
||||
show.season = FixEpisodeSeasonNumber(show.season)
|
||||
show.episode = FixEpisodeSeasonNumber(show.episode)
|
||||
|
||||
seasonFolder = "Season {0}".format(show.season)
|
||||
season = "S{0}".format(show.season)
|
||||
episode = "E{0}".format(show.episode)
|
||||
renamedFile = "{0}{1} - {2} - SD TV_.mpg".format(season, episode, show.subtitle)
|
||||
|
||||
directory = GetDirectory(show.title, seasonFolder)
|
||||
|
||||
def CheckTitleIsInList(serverAddress, user, password, database, inputFile):
|
||||
"""Check that inputFile is a recording of a show that is to be processed."""
|
||||
show = MythTV.RetrieveEpisodeData('localhost', 'script', 'script', 'mythconverg', file)
|
||||
|
||||
# TODO get this from settings
|
||||
if show.title in ["Thomas and Friends", "Thomas the Tank Engine & Friends",
|
||||
"Chuggington", "Mike the Knight", "Octonauts",
|
||||
"The Octonauts", "In the Night Garden",
|
||||
"Raa Raa! The Noisy Lion"]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def GetEpisodeName(subtitle, showName):
|
||||
if subtitle[:len(showName)].lower() == showName.lower():
|
||||
return subtitle[len(showName + ' and the '):]
|
||||
else:
|
||||
return subtitle
|
||||
Reference in New Issue
Block a user