From 85137d67894cca1628df54831ccf8240994dbd6b Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 20 May 2015 23:57:10 -0700 Subject: [PATCH] Started working on post process hooks --- autoProcess.ini.sample | 1 + manual.py | 1 + mkvtomp4.py | 8 ++++++++ readSettings.py | 10 +++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index 4274cd33..a78f98ed 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -43,6 +43,7 @@ download-subs=False embed-subs=True sub-providers=addic7ed,podnapisi,thesubdb,opensubtitles permissions=0777 +post-process=False [CouchPotato] host = localhost diff --git a/manual.py b/manual.py index 36fb0e25..1dca683c 100755 --- a/manual.py +++ b/manual.py @@ -206,6 +206,7 @@ def processFile(inputfile, tagdata, relativePath=None): if settings.relocate_moov: converter.QTFS(output['output']) converter.replicate(output['output'], relativePath=relativePath) + converter.post_process(output['output']) def walkDir(dir, silent=False, preserveRelative=False, tvdbid=None, tag=True): diff --git a/mkvtomp4.py b/mkvtomp4.py index 9dee3b50..ad924d95 100644 --- a/mkvtomp4.py +++ b/mkvtomp4.py @@ -40,6 +40,7 @@ def __init__( self, settings=None, embedsubs=True, providers=['addic7ed', 'podnapisi', 'thesubdb', 'opensubtitles'], permissions=int("777", 8), + post_process=False logger=None): # Setup Logging if logger: @@ -68,6 +69,7 @@ def __init__( self, settings=None, self.audio_codec=audio_codec self.audio_bitrate=audio_bitrate self.iOS=iOS + self.post_process=post_process self.iOSFirst=iOSFirst self.maxchannels=maxchannels self.awl=awl @@ -98,6 +100,7 @@ def importSettings(self, settings): self.moveto=settings.moveto self.relocate_moov = settings.relocate_moov self.permissions = settings.permissions + self.post_process = settings.post_process #Video settings self.video_codec=settings.vcodec self.video_bitrate=settings.vbitrate @@ -623,6 +626,11 @@ def replicate(self, inputfile, relativePath=None): except Exception as e: self.log.exception("Unable to move %s to %s" % (inputfile, moveto)) + # Runs any post process scripts + def post_process(self, inputfile): + print 'post_process' + print 'inputfile: ' + inputfile + # Robust file removal function, with options to retry in the event the file is in use, and replace a deleted file def removeFile(self, filename, retries=2, delay=10, replacement=None): for i in range(retries + 1): diff --git a/readSettings.py b/readSettings.py index 4c86a42c..b9544f5f 100644 --- a/readSettings.py +++ b/readSettings.py @@ -68,7 +68,8 @@ def __init__(self, directory, filename, logger=None): 'download-subs': 'False', 'embed-subs': 'True', 'sub-providers': 'addic7ed, podnapisi, thesubdb, opensubtitles', - 'permissions': '777' } + 'permissions': '777', + 'post-process': 'False' } # Default settings for CouchPotato cp_defaults = {'host': 'localhost', 'port': '5050', @@ -248,6 +249,13 @@ def __init__(self, directory, filename, logger=None): self.log.exception("Invalid permissions, defaulting to 777.") self.permissions = int("0777", 8) + self.post_process = config.get(section, 'post-process') + if self.post_process == "" or self.post_process.lower() in ['false', 'no', 'f', '0']: + self.post_process = False + else: + if self.post_process.lower() in ['true', 'yes', 't', '1']: + self.post_process = True + #Setup variable for maximum audio channels self.maxchannels = config.get(section, 'max-audio-channels') if self.maxchannels == "":