From 804db30b15051b9dab24d527c7c9df39fa77d2ce Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Fri, 2 May 2014 15:22:26 +0930 Subject: [PATCH 01/40] Adding notes --- classes/handbrake.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/classes/handbrake.py b/classes/handbrake.py index c61d598..e85b228 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -117,6 +117,12 @@ def convert(self, nice, args): args ] + # Subtitle changes + # -F, --subtitle-forced Only display subtitles from the selected stream if + # the subtitle has the forced flag set. + # -N, --native-language Specifiy your language preference. When the first + # -F --subtitle scan -N eng + proc = subprocess.Popen( command, stderr=subprocess.PIPE, From de403bff35d50a931d303aa6d013019a4abc37c8 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Fri, 2 May 2014 17:19:34 +0930 Subject: [PATCH 02/40] Moving doc blocks --- classes/handbrake.py | 110 ++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index e85b228..92c808b 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -22,47 +22,47 @@ class handBrake(object): def __init__(self, debug): self.log = logger.logger("Handbrake", debug) - """ Function: _cleanUp - Removes the log file and the input movie because these files are - no longer needed by this script + def _cleanUp(self, cFile): + """ Function: _cleanUp + Removes the log file and the input movie because these files are + no longer needed by this script - Inputs: - log (Str): File path of the log to remove - oldMovie (Str): File path of the movie to remove + Inputs: + log (Str): File path of the log to remove + oldMovie (Str): File path of the movie to remove - Outputs: - None - """ - def _cleanUp(self, cFile): + Outputs: + None + """ try: os.remove(cFile) except: self.log.error("Could not remove %s" % cFile) - """ Function: _updateQueue - Removes the recently processed movie from the queue so it's not - processed again + def _updateQueue(self, uStatus): + """ Function: _updateQueue + Removes the recently processed movie from the queue so it's not + processed again - Inputs: - None + Inputs: + None - Outputs: - None - """ - def _updateQueue(self, uStatus): + Outputs: + None + """ database.update_movie(self.dbMovie, uStatus) - """ Function: loadMovie - Check to see if the queue file exists, if it does load the first - line and proccess it for the rest of the script to use + def loadMovie(self): + """ Function: loadMovie + Check to see if the queue file exists, if it does load the first + line and proccess it for the rest of the script to use - Inputs: - None + Inputs: + None - Outputs: - None - """ - def loadMovie(self): + Outputs: + None + """ movie = database.next_movie() if movie is not None: @@ -76,24 +76,24 @@ def loadMovie(self): else: return False - """ Function: convert - Passes the nessesary parameters to HandBrake to start an encoding - Assigns a nice value to allow give normal system tasks priority - - Upon successful encode, clean up the output logs and remove the - input movie as they are no longer needed - - Inputs: - nice (Int): Priority to assign to task (nice value) - args (Str): All of the handbrake arguments taken from the - settings file - output (Str): File to log to. Used to see if the job completed - successfully - - Outputs: - None - """ def convert(self, nice, args): + """ Function: convert + Passes the nessesary parameters to HandBrake to start an encoding + Assigns a nice value to allow give normal system tasks priority + + Upon successful encode, clean up the output logs and remove the + input movie as they are no longer needed + + Inputs: + nice (Int): Priority to assign to task (nice value) + args (Str): All of the handbrake arguments taken from the + settings file + output (Str): File to log to. Used to see if the job completed + successfully + + Outputs: + None + """ checks = 0 inMovie = "%s/%s" % (self.path, self.inputMovie) outMovie = "%s/%s" % (self.path, self.outputMovie) @@ -101,6 +101,10 @@ def convert(self, nice, args): if not os.path.isfile(inMovie): self.log.debug(inMovie) self.log.error("Input file no longer exists") + database.insert_history( + self.dbMovie, "Input file no longer exists", 4 + ) + return False command = [ @@ -170,14 +174,14 @@ def convert(self, nice, args): database.insert_history(self.dbMovie, "Handbrake failed", 4) return False - """ Function: getMovieTitle - Returns the currently loaded movie title + def getMovieTitle(self): + """ Function: getMovieTitle + Returns the currently loaded movie title - Inputs: - None + Inputs: + None - Outputs: - self.movie (Str): Movie title parsed from queue - """ - def getMovieTitle(self): + Outputs: + self.movie (Str): Movie title parsed from queue + """ return self.outputMovie From 9e8acabd300b37fb7768a0b00c330bcae587194a Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 5 May 2014 17:08:24 +0930 Subject: [PATCH 03/40] Adding filebot command line option Don't know if I'll proceed down this path of more command line options, but I'll try it out anyway --- autorip.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autorip.py b/autorip.py index 9efcc6c..55282cf 100644 --- a/autorip.py +++ b/autorip.py @@ -31,15 +31,19 @@ @license http://opensource.org/licenses/MIT Usage: - autorip.py ( --rip | --compress | ( --rip --compress) ) [options] + autorip.py --rip | --compress | --extra [options] + autorip.py ( --rip --compress --extra ) [options] + autorip.py --all [options] Options: - -h --help Show this screen. - --version Show version. - --debug Output debug. - --rip Rip disc using makeMKV. - --compress Compress using handbrake. - --test Testing? + -h --help Show this screen. + --version Show version. + --debug Output debug. + --rip Rip disc using makeMKV. + --compress Compress using HandBrake. + --extra Lookup, rename and/or download extras. + --all Do everything + --test Testing? """ From 1e952c9d954e3546b578e134dcaef7945cab6b98 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Sun, 20 Jul 2014 18:36:18 +0930 Subject: [PATCH 04/40] Adding in basic filebot --- autorip.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index 72eb79a..3ecfd33 100644 --- a/autorip.py +++ b/autorip.py @@ -43,7 +43,6 @@ --compress Compress using HandBrake. --extra Lookup, rename and/or download extras. --all Do everything - --test Testing? """ @@ -216,6 +215,14 @@ def compress(config): else: log.info( "Queue does not exist or is empty") +def filebot(config): + """ + Main function for filebotting + Does everything + Returns nothing + """ + fb = filebot.filebot(config['debug']) + if __name__ == '__main__': arguments = docopt.docopt(__doc__, version=__version__) @@ -231,3 +238,7 @@ def compress(config): if arguments['--compress']: compress(config) + + if arguments['--extra']: + filebot(config) + From 480981411eb2185ba9f0173bfa5a143193107758 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 10:13:51 +0930 Subject: [PATCH 05/40] adding --all argument --- autorip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index 72eb79a..9fadef8 100644 --- a/autorip.py +++ b/autorip.py @@ -226,8 +226,8 @@ def compress(config): if bool(config['analytics']['enable']): analytics.ping(__version__) - if arguments['--rip']: + if arguments['--rip'] or arguments['--all']: rip(config) - if arguments['--compress']: + if arguments['--compress'] or arguments['--all']: compress(config) From e065c46be23050d4b731c3502868392d673a30cf Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 10:15:02 +0930 Subject: [PATCH 06/40] next_movie -> next_movie_to_compress --- classes/database.py | 8 ++++++-- classes/handbrake.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/database.py b/classes/database.py index c4f5496..a48d888 100644 --- a/classes/database.py +++ b/classes/database.py @@ -102,10 +102,14 @@ def create_statusTypes(): for sID, sType in statusTypes: Statustypes.create(statusid=sID, statustext=sType) -def next_movie(): +def next_movie_to_compress(): for movie in Movies.select().where((Movies.statusid == 4) | (Movies.filename != None )): return movie +def next_movie_to_filebot(): + for movie in Movies.select().where((Movies.statusid == 6) | (Movies.filename != None )): + return movie + def insert_history(dbMovie, text, typeid=1): return History.create( movieid=dbMovie.movieid, @@ -140,4 +144,4 @@ def dbintegritycheck(): create_historyTypes() create_statusTypes() -dbintegritycheck() \ No newline at end of file +dbintegritycheck() diff --git a/classes/handbrake.py b/classes/handbrake.py index 92c808b..20418ff 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -63,7 +63,7 @@ def loadMovie(self): Outputs: None """ - movie = database.next_movie() + movie = database.next_movie_to_compress() if movie is not None: self.ID = movie.movieid From 6abf14ae976d7a3622619af2d6410bfde85ed220 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 10:22:00 +0930 Subject: [PATCH 07/40] adding --all to filebot --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index 285570b..712face 100644 --- a/autorip.py +++ b/autorip.py @@ -239,6 +239,6 @@ def filebot(config): if arguments['--compress'] or arguments['--all']: compress(config) - if arguments['--extra']: + if arguments['--extra'] or arguments['--all']: filebot(config) From deeb60f233a56b2d2ca42b8cee953b24b99fbeeb Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 10:22:25 +0930 Subject: [PATCH 08/40] Removing unused database import --- classes/makemkv.py | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/makemkv.py b/classes/makemkv.py index ba6f648..3a5606b 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -15,7 +15,6 @@ import os import re import csv -import database import logger class makeMKV(object): From fbe08ca41d33d1a82c5b6405622bc071911f8880 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 11:01:23 +0930 Subject: [PATCH 09/40] Removing database from handbrake class This still needs to be tested --- autorip.py | 53 +++++++++++++++++++------- classes/filebot.py | 2 - classes/handbrake.py | 88 ++++++++------------------------------------ 3 files changed, 55 insertions(+), 88 deletions(-) diff --git a/autorip.py b/autorip.py index 712face..5c1e67b 100644 --- a/autorip.py +++ b/autorip.py @@ -191,26 +191,51 @@ def compress(config): hb = handbrake.handBrake(config['debug']) - log.debug("Compressing started successfully") + log.debug("Compressing initialised") log.debug("Looking for movies to compress") - if hb.loadMovie(): - log.info( "Compressing %s" % hb.getMovieTitle()) + dbMovie = database.next_movie_to_compress() - with stopwatch.stopwatch() as t: - convert = hb.convert( - args=config['handbrake']['com'], - nice=int(config['handbrake']['nice']) - ) + if dbMovie is not None: + if hb.check_exists(dbMovie) is not False: - if convert: - log.info("Movie was compressed and encoded successfully") + database.update_movie(dbMovie, 5) - log.info( ("It took %s minutes to compress %s" % - (t.minutes, hb.getMovieTitle())) - ) + log.info( "Compressing %s" % dbMovie.moviename ) + + with stopwatch.stopwatch() as t: + status = hb.convert( + args=config['handbrake']['com'], + nice=int(config['handbrake']['nice']) + moviedb=dbMovie + ) + + if status: + log.info("Movie was compressed and encoded successfully") + + log.info( ("It took %s minutes to compress %s" % + (t.minutes, hb.getMovieTitle())) + ) + + database.insert_history( + self.dbMovie, + "HandBakeCLI Completed successfully" + ) + + database.update_movie(dbMovie, 6) + + else: + database.update_movie(dbMovie, 5) + + database.insert_history(self.dbMovie, "Handbrake failed", 4) + + log.info( "HandBrake did not complete successfully") else: - log.info( "HandBrake did not complete successfully") + database.update_movie(dbMovie, 2) + + database.insert_history( + self.dbMovie, "Input file no longer exists", 4 + ) else: log.info( "Queue does not exist or is empty") diff --git a/classes/filebot.py b/classes/filebot.py index ad7c5ec..3b0a04a 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -13,14 +13,12 @@ import os import subprocess -import database import logger class filebot(object): def __init__(self, debug): - self.db = database.database() self.log = logger.logger("Filebot", debug) def rename(self): diff --git a/classes/handbrake.py b/classes/handbrake.py index 20418ff..af55505 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -13,7 +13,6 @@ import os import subprocess -import database import logger @@ -39,44 +38,15 @@ def _cleanUp(self, cFile): except: self.log.error("Could not remove %s" % cFile) - def _updateQueue(self, uStatus): - """ Function: _updateQueue - Removes the recently processed movie from the queue so it's not - processed again + def check_exists(self, moviedb): + inMovie = "%s/%s" % (moviedb.path, moviedb.filename) - Inputs: - None - - Outputs: - None - """ - database.update_movie(self.dbMovie, uStatus) - - def loadMovie(self): - """ Function: loadMovie - Check to see if the queue file exists, if it does load the first - line and proccess it for the rest of the script to use - - Inputs: - None - - Outputs: - None - """ - movie = database.next_movie_to_compress() - - if movie is not None: - self.ID = movie.movieid - self.path = movie.path - self.inputMovie = movie.filename - self.outputMovie = "%s.mkv" % movie.moviename - self.dbMovie = movie - - return True - else: + if not os.path.isfile(inMovie): + self.log.debug(inMovie) + self.log.error("Input file no longer exists") return False - def convert(self, nice, args): + def convert(self, nice, args, moviedb): """ Function: convert Passes the nessesary parameters to HandBrake to start an encoding Assigns a nice value to allow give normal system tasks priority @@ -95,17 +65,9 @@ def convert(self, nice, args): None """ checks = 0 - inMovie = "%s/%s" % (self.path, self.inputMovie) - outMovie = "%s/%s" % (self.path, self.outputMovie) - - if not os.path.isfile(inMovie): - self.log.debug(inMovie) - self.log.error("Input file no longer exists") - database.insert_history( - self.dbMovie, "Input file no longer exists", 4 - ) - return False + inMovie = "%s/%s" % (moviedb.path, moviedb.filename) + outMovie = "%s/%s" % (dbMovie.path, moviename) command = [ 'nice', @@ -136,52 +98,34 @@ def convert(self, nice, args): if proc.stderr is not None: output = proc.stderr.read() if len(output) is not 0: - self.log.error("HandBakeCLI encountered the following error: ") + self.log.error("HandBrakeCLI encountered the following error: ") lines = output.split("\n") for line in lines: self.log.error(line.strip()) - database.insert_history(self.dbMovie, line, 4) - self._updateQueue(2) return False output = proc.stdout.read() lines = output.split("\n") for line in lines: self.log.debug(line.strip()) + if "average encoding speed for job" in line: checks += 1 + if "Encode done!" in line: checks += 1 + if "ERROR" in line: - self.log.error("HandBakeCLI encountered the following error: ") + self.log.error("HandBrakeCLI encountered the following error: ") self.log.error(line) - self._updateQueue(2) - database.insert_history(self.dbMovie, line, 4) + return False if checks == 2: - self.log.debug("HandBakeCLI Completed successfully") - self._updateQueue(6) + self.log.debug("HandBrakeCLI Completed successfully") self._cleanUp(cFile=inMovie) self._cleanUp(cFile=output) - database.insert_history( - self.dbMovie, - "HandBakeCLI Completed successfully" - ) + return True else: - self._updateQueue(2) - database.insert_history(self.dbMovie, "Handbrake failed", 4) return False - - def getMovieTitle(self): - """ Function: getMovieTitle - Returns the currently loaded movie title - - Inputs: - None - - Outputs: - self.movie (Str): Movie title parsed from queue - """ - return self.outputMovie From e14fb37a07d5cbe5935df16e5a363c08903b563e Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 11:06:45 +0930 Subject: [PATCH 10/40] Adding missing , --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index 5c1e67b..1974f1a 100644 --- a/autorip.py +++ b/autorip.py @@ -206,7 +206,7 @@ def compress(config): with stopwatch.stopwatch() as t: status = hb.convert( args=config['handbrake']['com'], - nice=int(config['handbrake']['nice']) + nice=int(config['handbrake']['nice']), moviedb=dbMovie ) From dbae6f2a6d3a8e73576a68fb7264de11b4b5764e Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 13:35:21 +0930 Subject: [PATCH 11/40] Fixing command line args --- autorip.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/autorip.py b/autorip.py index 1974f1a..c7b0eab 100644 --- a/autorip.py +++ b/autorip.py @@ -31,9 +31,8 @@ @license http://opensource.org/licenses/MIT Usage: - autorip.py --rip | --compress | --extra [options] - autorip.py ( --rip --compress --extra ) [options] - autorip.py --all [options] + autorip.py ( --rip | --compress | --extra ) [options] + autorip.py ( --rip --compress --extra ) [options] Options: -h --help Show this screen. @@ -225,16 +224,16 @@ def compress(config): database.update_movie(dbMovie, 6) else: - database.update_movie(dbMovie, 5) + #database.update_movie(dbMovie, 5) - database.insert_history(self.dbMovie, "Handbrake failed", 4) + database.insert_history(dbMovie, "Handbrake failed", 4) log.info( "HandBrake did not complete successfully") else: database.update_movie(dbMovie, 2) database.insert_history( - self.dbMovie, "Input file no longer exists", 4 + dbMovie, "Input file no longer exists", 4 ) else: From e9cc8afe60e882e811e2f2b252a84b8bda9ddcec Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 13:35:51 +0930 Subject: [PATCH 12/40] debugging handbrake proccess... --- classes/handbrake.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index af55505..d8eda5d 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -66,8 +66,9 @@ def convert(self, nice, args, moviedb): """ checks = 0 + moviename = "%s.mkv" % moviedb.moviename inMovie = "%s/%s" % (moviedb.path, moviedb.filename) - outMovie = "%s/%s" % (dbMovie.path, moviename) + outMovie = "%s/%s" % (moviedb.path, moviename) command = [ 'nice', @@ -83,6 +84,8 @@ def convert(self, nice, args, moviedb): args ] + print " ".join(command) + # Subtitle changes # -F, --subtitle-forced Only display subtitles from the selected stream if # the subtitle has the forced flag set. @@ -98,7 +101,6 @@ def convert(self, nice, args, moviedb): if proc.stderr is not None: output = proc.stderr.read() if len(output) is not 0: - self.log.error("HandBrakeCLI encountered the following error: ") lines = output.split("\n") for line in lines: self.log.error(line.strip()) @@ -123,8 +125,8 @@ def convert(self, nice, args, moviedb): if checks == 2: self.log.debug("HandBrakeCLI Completed successfully") - self._cleanUp(cFile=inMovie) - self._cleanUp(cFile=output) + #self._cleanUp(cFile=inMovie) + #self._cleanUp(cFile=output) return True else: From bfe2afa8c3f65f1ac9a85d04319948c60a4349ea Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 13:41:50 +0930 Subject: [PATCH 13/40] Handbrake trickery --- classes/handbrake.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index d8eda5d..c2e3db6 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -98,13 +98,38 @@ def convert(self, nice, args, moviedb): stdout=subprocess.PIPE ) + # I'm a little confused here + # handbrake cli spits out stdout into stderr + # so I'll parse both stderr and stdout + if proc.stderr is not None: output = proc.stderr.read() if len(output) is not 0: lines = output.split("\n") for line in lines: - self.log.error(line.strip()) - return False + self.log.debug(line.strip()) + + if "average encoding speed for job" in line: + checks += 1 + + if "Encode done!" in line: + checks += 1 + + if "ERROR" in line: + self.log.error("HandBrakeCLI encountered the following error: ") + self.log.error(line) + + return False + + if checks >= 2: + self.log.debug("HandBrakeCLI Completed successfully") + #self._cleanUp(cFile=inMovie) + #self._cleanUp(cFile=output) + + return True + else: + return False + output = proc.stdout.read() lines = output.split("\n") @@ -123,7 +148,7 @@ def convert(self, nice, args, moviedb): return False - if checks == 2: + if checks >= 2: self.log.debug("HandBrakeCLI Completed successfully") #self._cleanUp(cFile=inMovie) #self._cleanUp(cFile=output) From f0514920a76d19c0e7d2cbd556222433f9d2ef01 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 14:19:34 +0930 Subject: [PATCH 14/40] Fixing getMovieTitle --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index c7b0eab..ef65461 100644 --- a/autorip.py +++ b/autorip.py @@ -213,7 +213,7 @@ def compress(config): log.info("Movie was compressed and encoded successfully") log.info( ("It took %s minutes to compress %s" % - (t.minutes, hb.getMovieTitle())) + (t.minutes, dbMovie.moviename)) ) database.insert_history( From 626011722c1a589b5121ada2360a852d881f2e74 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 14:23:31 +0930 Subject: [PATCH 15/40] removing self. --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index ef65461..975a938 100644 --- a/autorip.py +++ b/autorip.py @@ -217,7 +217,7 @@ def compress(config): ) database.insert_history( - self.dbMovie, + dbMovie, "HandBakeCLI Completed successfully" ) From 04eb1051d0a7bc8aa3fd55158f7fbeee4f65dcce Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 14:36:13 +0930 Subject: [PATCH 16/40] Removing printing and debug --- classes/handbrake.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index c2e3db6..05f59e3 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -84,8 +84,6 @@ def convert(self, nice, args, moviedb): args ] - print " ".join(command) - # Subtitle changes # -F, --subtitle-forced Only display subtitles from the selected stream if # the subtitle has the forced flag set. @@ -123,8 +121,8 @@ def convert(self, nice, args, moviedb): if checks >= 2: self.log.debug("HandBrakeCLI Completed successfully") - #self._cleanUp(cFile=inMovie) - #self._cleanUp(cFile=output) + self._cleanUp(cFile=inMovie) + self._cleanUp(cFile=output) return True else: @@ -150,8 +148,8 @@ def convert(self, nice, args, moviedb): if checks >= 2: self.log.debug("HandBrakeCLI Completed successfully") - #self._cleanUp(cFile=inMovie) - #self._cleanUp(cFile=output) + self._cleanUp(cFile=inMovie) + self._cleanUp(cFile=output) return True else: From 79eb9b3abacafedd071f392051817fdb27328d27 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 14:38:55 +0930 Subject: [PATCH 17/40] AND not OR --- classes/database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/database.py b/classes/database.py index a48d888..3d652da 100644 --- a/classes/database.py +++ b/classes/database.py @@ -103,11 +103,11 @@ def create_statusTypes(): Statustypes.create(statusid=sID, statustext=sType) def next_movie_to_compress(): - for movie in Movies.select().where((Movies.statusid == 4) | (Movies.filename != None )): + for movie in Movies.select().where((Movies.statusid == 4) & (Movies.filename != None )): return movie def next_movie_to_filebot(): - for movie in Movies.select().where((Movies.statusid == 6) | (Movies.filename != None )): + for movie in Movies.select().where((Movies.statusid == 6) & (Movies.filename != None )): return movie def insert_history(dbMovie, text, typeid=1): From 6fd4367752341e615c10556dc29ed9cb71190719 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 14:39:27 +0930 Subject: [PATCH 18/40] Only find filebot enable movies --- classes/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/database.py b/classes/database.py index 3d652da..b6a2358 100644 --- a/classes/database.py +++ b/classes/database.py @@ -107,7 +107,7 @@ def next_movie_to_compress(): return movie def next_movie_to_filebot(): - for movie in Movies.select().where((Movies.statusid == 6) & (Movies.filename != None )): + for movie in Movies.select().where((Movies.statusid == 6) & (Movies.filename != None ) & (Movies.filebot == 1 )): return movie def insert_history(dbMovie, text, typeid=1): From 897503440206ad29cb5e99d685328bb699410ccc Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 14:53:47 +0930 Subject: [PATCH 19/40] Update movie name and movie status --- autorip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index 975a938..8006d38 100644 --- a/autorip.py +++ b/autorip.py @@ -224,13 +224,13 @@ def compress(config): database.update_movie(dbMovie, 6) else: - #database.update_movie(dbMovie, 5) + database.update_movie(dbMovie, 5) database.insert_history(dbMovie, "Handbrake failed", 4) log.info( "HandBrake did not complete successfully") else: - database.update_movie(dbMovie, 2) + database.update_movie(dbMovie, 2, filename="%s.mkv" % moviedb.moviename) database.insert_history( dbMovie, "Input file no longer exists", 4 From 5e774ed688d8c900031bec76e4844fa4e148a3d6 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 15:16:04 +0930 Subject: [PATCH 20/40] Moving filename update --- autorip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index 8006d38..16ec332 100644 --- a/autorip.py +++ b/autorip.py @@ -221,7 +221,7 @@ def compress(config): "HandBakeCLI Completed successfully" ) - database.update_movie(dbMovie, 6) + database.update_movie(dbMovie, 6, filename="%s.mkv" % moviedb.moviename) else: database.update_movie(dbMovie, 5) @@ -230,7 +230,7 @@ def compress(config): log.info( "HandBrake did not complete successfully") else: - database.update_movie(dbMovie, 2, filename="%s.mkv" % moviedb.moviename) + database.update_movie(dbMovie, 2) database.insert_history( dbMovie, "Input file no longer exists", 4 From 3c761a24d43bcb5d5b701292a8c7448b888df665 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 15:19:54 +0930 Subject: [PATCH 21/40] Trying stderr > stdout --- classes/handbrake.py | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index 05f59e3..c423ea5 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -81,7 +81,8 @@ def convert(self, nice, args, moviedb): str(inMovie), '-o', str(outMovie), - args + args, + '2>&1' ] # Subtitle changes @@ -92,43 +93,9 @@ def convert(self, nice, args, moviedb): proc = subprocess.Popen( command, - stderr=subprocess.PIPE, stdout=subprocess.PIPE ) - # I'm a little confused here - # handbrake cli spits out stdout into stderr - # so I'll parse both stderr and stdout - - if proc.stderr is not None: - output = proc.stderr.read() - if len(output) is not 0: - lines = output.split("\n") - for line in lines: - self.log.debug(line.strip()) - - if "average encoding speed for job" in line: - checks += 1 - - if "Encode done!" in line: - checks += 1 - - if "ERROR" in line: - self.log.error("HandBrakeCLI encountered the following error: ") - self.log.error(line) - - return False - - if checks >= 2: - self.log.debug("HandBrakeCLI Completed successfully") - self._cleanUp(cFile=inMovie) - self._cleanUp(cFile=output) - - return True - else: - return False - - output = proc.stdout.read() lines = output.split("\n") for line in lines: @@ -140,7 +107,7 @@ def convert(self, nice, args, moviedb): if "Encode done!" in line: checks += 1 - if "ERROR" in line: + if "ERROR" in line and "opening" not in line: self.log.error("HandBrakeCLI encountered the following error: ") self.log.error(line) From 118a1865d81dc595872f2aab9e8d2fb42b07126b Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 15:21:38 +0930 Subject: [PATCH 22/40] Fixing clargs again --- autorip.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index 16ec332..b90e655 100644 --- a/autorip.py +++ b/autorip.py @@ -31,8 +31,9 @@ @license http://opensource.org/licenses/MIT Usage: - autorip.py ( --rip | --compress | --extra ) [options] - autorip.py ( --rip --compress --extra ) [options] + autorip.py ( --rip | --compress | --extra ) [options] + autorip.py ( --rip [ --compress ] ) [options] + autorip.py --all [options] Options: -h --help Show this screen. From 4e3c4397c194decb07258579f5574275272efb9a Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 15:32:39 +0930 Subject: [PATCH 23/40] Putting stderr back in --- classes/handbrake.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index c423ea5..be516c5 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -93,9 +93,43 @@ def convert(self, nice, args, moviedb): proc = subprocess.Popen( command, - stdout=subprocess.PIPE + stdout=subprocess.PIPE, + stderr=subprocess.PIPE ) + # I'm a little confused here + # handbrake cli spits out stdout into stderr + # so I'll parse both stderr and stdout + + if proc.stderr is not None: + output = proc.stderr.read() + if len(output) is not 0: + lines = output.split("\n") + for line in lines: + self.log.debug(line.strip()) + + if "average encoding speed for job" in line: + checks += 1 + + if "Encode done!" in line: + checks += 1 + + if "ERROR" in line and "opening" not in line: + self.log.error("HandBrakeCLI encountered the following error: ") + self.log.error(line) + + return False + + if checks >= 2: + self.log.debug("HandBrakeCLI Completed successfully") + self._cleanUp(cFile=inMovie) + self._cleanUp(cFile=output) + + return True + else: + return False + + output = proc.stdout.read() lines = output.split("\n") for line in lines: From 86b35baf5e3b082365275fa5f2f35e3f7721852a Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 16:05:27 +0930 Subject: [PATCH 24/40] dbMovie not moviedb --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index b90e655..e3ad501 100644 --- a/autorip.py +++ b/autorip.py @@ -222,7 +222,7 @@ def compress(config): "HandBakeCLI Completed successfully" ) - database.update_movie(dbMovie, 6, filename="%s.mkv" % moviedb.moviename) + database.update_movie(dbMovie, 6, filename="%s.mkv" % dbMovie.moviename) else: database.update_movie(dbMovie, 5) From 6fd697f64483393d1cd7960c2347590e221578d4 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 16:18:25 +0930 Subject: [PATCH 25/40] No more removing stderr... not an over bright idea --- classes/handbrake.py | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index be516c5..09b884a 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -19,7 +19,7 @@ class handBrake(object): def __init__(self, debug): - self.log = logger.logger("Handbrake", debug) + self.log = logger.logger("Handbrake CLI", debug) def _cleanUp(self, cFile): """ Function: _cleanUp @@ -106,7 +106,7 @@ def convert(self, nice, args, moviedb): if len(output) is not 0: lines = output.split("\n") for line in lines: - self.log.debug(line.strip()) + #self.log.debug(line.strip()) if "average encoding speed for job" in line: checks += 1 @@ -123,35 +123,8 @@ def convert(self, nice, args, moviedb): if checks >= 2: self.log.debug("HandBrakeCLI Completed successfully") self._cleanUp(cFile=inMovie) - self._cleanUp(cFile=output) return True else: return False - - output = proc.stdout.read() - lines = output.split("\n") - for line in lines: - self.log.debug(line.strip()) - - if "average encoding speed for job" in line: - checks += 1 - - if "Encode done!" in line: - checks += 1 - - if "ERROR" in line and "opening" not in line: - self.log.error("HandBrakeCLI encountered the following error: ") - self.log.error(line) - - return False - - if checks >= 2: - self.log.debug("HandBrakeCLI Completed successfully") - self._cleanUp(cFile=inMovie) - self._cleanUp(cFile=output) - - return True - else: - return False From 7daff57b1e73d8d39468c34b8f891f6199a042f6 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:21:48 +0930 Subject: [PATCH 26/40] docblocks --- classes/handbrake.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index 09b884a..6bd067b 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -23,12 +23,9 @@ def __init__(self, debug): def _cleanUp(self, cFile): """ Function: _cleanUp - Removes the log file and the input movie because these files are - no longer needed by this script Inputs: - log (Str): File path of the log to remove - oldMovie (Str): File path of the movie to remove + cFile (Str): File path of the movie to remove Outputs: None @@ -99,14 +96,14 @@ def convert(self, nice, args, moviedb): # I'm a little confused here # handbrake cli spits out stdout into stderr - # so I'll parse both stderr and stdout + # so I'll parse stderr as stdout if proc.stderr is not None: output = proc.stderr.read() if len(output) is not 0: lines = output.split("\n") for line in lines: - #self.log.debug(line.strip()) + self.log.debug(line.strip()) if "average encoding speed for job" in line: checks += 1 From 57bc4d06a19375f4854bc716ef055144e87df6ea Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:23:40 +0930 Subject: [PATCH 27/40] filebot() -> extras() --- autorip.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index e3ad501..a44c74d 100644 --- a/autorip.py +++ b/autorip.py @@ -240,14 +240,19 @@ def compress(config): else: log.info( "Queue does not exist or is empty") -def filebot(config): +def extras(config): """ Main function for filebotting Does everything Returns nothing """ + log = logger.logger("Extras", config['debug']) + fb = filebot.filebot(config['debug']) + dbMovie = database.next_movie_to_filebot() + + print dbMovie if __name__ == '__main__': arguments = docopt.docopt(__doc__, version=__version__) @@ -265,5 +270,5 @@ def filebot(config): compress(config) if arguments['--extra'] or arguments['--all']: - filebot(config) + extras(config) From 01079a059d50c2cf8330427c055ff7ea4661509e Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:25:18 +0930 Subject: [PATCH 28/40] Adding filebot class to init --- classes/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/__init__.py b/classes/__init__.py index 841a93f..2a2a6a0 100644 --- a/classes/__init__.py +++ b/classes/__init__.py @@ -2,6 +2,7 @@ 'analytics', 'database', 'docopt', + 'filebot', 'handbrake', 'logger', 'makemkv', From e29b3900a21ad89ce571596df8334377c0097528 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:33:38 +0930 Subject: [PATCH 29/40] filebot renaming start! --- autorip.py | 4 +++- classes/filebot.py | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/autorip.py b/autorip.py index a44c74d..e4bcec4 100644 --- a/autorip.py +++ b/autorip.py @@ -252,7 +252,9 @@ def extras(config): dbMovie = database.next_movie_to_filebot() - print dbMovie + fb.rename(dbMovie) + + if __name__ == '__main__': arguments = docopt.docopt(__doc__, version=__version__) diff --git a/classes/filebot.py b/classes/filebot.py index 3b0a04a..f2bdd2a 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -21,10 +21,28 @@ class filebot(object): def __init__(self, debug): self.log = logger.logger("Filebot", debug) - def rename(self): - # filebot -rename title00.mkv --q [Movie Name] -non-strict + def rename(self, dbMovie): + + command = [ + 'filebot', + '-rename', + "%s/%s" % (moviedb.path, moviedb.filename), + '--q', + moviedb.moviename, + '-non-strict' + ] + + proc = subprocess.Popen( + command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + print proc.stdout.read() + + # filebot -rename title00.mkv --q [Movie Name] # [MOVE] Rename [/tmp/Euro Trip G1/Road Trip (2000).mkv] to [EuroTrip (2004).mkv] - pass + def subtitles(self): # filebot -get-missing-subtitles --lang From 705f6b072688c4a394b9fe6176ff2e13a2d2c37b Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:35:50 +0930 Subject: [PATCH 30/40] log.info( "No movies ready for filebot") --- autorip.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autorip.py b/autorip.py index e4bcec4..be5fa4e 100644 --- a/autorip.py +++ b/autorip.py @@ -252,9 +252,11 @@ def extras(config): dbMovie = database.next_movie_to_filebot() - fb.rename(dbMovie) - + if dbMovie is not None: + fb.rename(dbMovie) + else: + log.info( "No movies ready for filebot") if __name__ == '__main__': arguments = docopt.docopt(__doc__, version=__version__) From b96d66d3c324564f41b8a6b241ab54e3233fbe5b Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:37:17 +0930 Subject: [PATCH 31/40] dbMovie not moviedb --- autorip.py | 2 +- classes/filebot.py | 4 ++-- classes/handbrake.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autorip.py b/autorip.py index be5fa4e..cb25965 100644 --- a/autorip.py +++ b/autorip.py @@ -207,7 +207,7 @@ def compress(config): status = hb.convert( args=config['handbrake']['com'], nice=int(config['handbrake']['nice']), - moviedb=dbMovie + dbMovie=dbMovie ) if status: diff --git a/classes/filebot.py b/classes/filebot.py index f2bdd2a..7bb6b0f 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -26,9 +26,9 @@ def rename(self, dbMovie): command = [ 'filebot', '-rename', - "%s/%s" % (moviedb.path, moviedb.filename), + "%s/%s" % (dbMovie.path, dbMovie.filename), '--q', - moviedb.moviename, + dbMovie.moviename, '-non-strict' ] diff --git a/classes/handbrake.py b/classes/handbrake.py index 6bd067b..32bfe46 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -35,15 +35,15 @@ def _cleanUp(self, cFile): except: self.log.error("Could not remove %s" % cFile) - def check_exists(self, moviedb): - inMovie = "%s/%s" % (moviedb.path, moviedb.filename) + def check_exists(self, dbMovie): + inMovie = "%s/%s" % (dbMovie.path, dbMovie.filename) if not os.path.isfile(inMovie): self.log.debug(inMovie) self.log.error("Input file no longer exists") return False - def convert(self, nice, args, moviedb): + def convert(self, nice, args, dbMovie): """ Function: convert Passes the nessesary parameters to HandBrake to start an encoding Assigns a nice value to allow give normal system tasks priority @@ -63,9 +63,9 @@ def convert(self, nice, args, moviedb): """ checks = 0 - moviename = "%s.mkv" % moviedb.moviename - inMovie = "%s/%s" % (moviedb.path, moviedb.filename) - outMovie = "%s/%s" % (moviedb.path, moviename) + moviename = "%s.mkv" % dbMovie.moviename + inMovie = "%s/%s" % (dbMovie.path, dbMovie.filename) + outMovie = "%s/%s" % (dbMovie.path, moviename) command = [ 'nice', From b42933cf73fa05b2833d2208aab3d51866f2c7d9 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:42:37 +0930 Subject: [PATCH 32/40] More filebot options --- classes/filebot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index 7bb6b0f..5658683 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -28,8 +28,10 @@ def rename(self, dbMovie): '-rename', "%s/%s" % (dbMovie.path, dbMovie.filename), '--q', - dbMovie.moviename, - '-non-strict' + "\"%s\"" % dbMovie.moviename, + '-non-strict', + '--db', + 'OpenSubtitles' ] proc = subprocess.Popen( From bdac595c9190e3c3c188d7caa545f9f47bb7ec17 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 16:48:52 +0930 Subject: [PATCH 33/40] Reading filebot stdout --- classes/filebot.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index 5658683..238c7be 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -40,10 +40,29 @@ def rename(self, dbMovie): stderr=subprocess.PIPE ) - print proc.stdout.read() - # filebot -rename title00.mkv --q [Movie Name] - # [MOVE] Rename [/tmp/Euro Trip G1/Road Trip (2000).mkv] to [EuroTrip (2004).mkv] + output = proc.stdout.read() + renamedMovie = "" + checks = 0 + + if len(output) is not 0: + lines = output.split("\n") + for line in lines: + if "MOVE" in line: + renamedMovie = line.split("] to [", 1)[1].rstrip(']') + checks += 1 + + print renamedMovie + + if "Processed" in line: + checks += 1 + + if "Done" in line: + checks += 1 + + if checks >= 3: + print "Success" + return True def subtitles(self): From de23996680aca9772ecefe828066447f5089f517 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 17:10:11 +0930 Subject: [PATCH 34/40] Now with subtitle downloading --- autorip.py | 31 +++++++++++++++++++++++++- classes/filebot.py | 55 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/autorip.py b/autorip.py index cb25965..984ca6b 100644 --- a/autorip.py +++ b/autorip.py @@ -253,11 +253,40 @@ def extras(config): dbMovie = database.next_movie_to_filebot() if dbMovie is not None: - fb.rename(dbMovie) + log.info( "Attempting movie rename" ) + + database.update_movie(dbMovie, 7) + + status = fb.rename(dbMovie) + + if status[0]: + log.info( "Rename success") + database.update_movie(dbMovie, 6, filename=status[1]) + + if config['filebot']['subtitles']: + log.info( "Grabbing subtitles" ) + + status = fb.get_subtitles(dbMovie) + + if status: + log.info( "Subtitles downloaded" ) + database.update_movie(dbMovie, 8) + + else: + log.info( "Subtitles not downloaded, no match" ) + database.update_movie(dbMovie, 8) + + else: + log.info( "Not grabbing subtitles" ) + database.update_movie(dbMovie, 8) + + else: + log.info( "Rename failed") else: log.info( "No movies ready for filebot") + if __name__ == '__main__': arguments = docopt.docopt(__doc__, version=__version__) config = yaml.safe_load(open(CONFIG_FILE)) diff --git a/classes/filebot.py b/classes/filebot.py index 238c7be..7bb7222 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -40,7 +40,6 @@ def rename(self, dbMovie): stderr=subprocess.PIPE ) - output = proc.stdout.read() renamedMovie = "" checks = 0 @@ -48,11 +47,51 @@ def rename(self, dbMovie): if len(output) is not 0: lines = output.split("\n") for line in lines: + self.log.debug(line.strip()) if "MOVE" in line: renamedMovie = line.split("] to [", 1)[1].rstrip(']') checks += 1 - print renamedMovie + if "Processed" in line: + checks += 1 + + if "Done" in line: + checks += 1 + + if checks >= 3 and renamedMovie: + return [True, renamedMovie] + + else: + return [False] + + def get_subtitles(self, dbMovie, lang): + command = [ + 'filebot', + '-get-subtitles', + dbMovie.path, + '--q', + "\"%s\"" % dbMovie.moviename, + '--lang', + lang, + '--output', + 'srt', + '--encoding', + 'utf8', + '-non-strict' + ] + + proc = subprocess.Popen( + command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + checks = 0 + + if len(output) is not 0: + lines = output.split("\n") + for line in lines: + self.log.debug(line.strip()) if "Processed" in line: checks += 1 @@ -60,14 +99,8 @@ def rename(self, dbMovie): if "Done" in line: checks += 1 - if checks >= 3: - print "Success" + if checks >= 2: return True - - def subtitles(self): - # filebot -get-missing-subtitles --lang - # Matched - # Fetching - # Writing - pass + else: + return False \ No newline at end of file From a15903dd8c422bc9de254b44e64858d4867f5971 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 17:10:18 +0930 Subject: [PATCH 35/40] Removing the 'runAfter' --- settings.example.cfg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/settings.example.cfg b/settings.example.cfg index f08645b..90b0f24 100644 --- a/settings.example.cfg +++ b/settings.example.cfg @@ -33,10 +33,6 @@ filebot: # Enable filebot renaming enable: True - # When to run filebot (if enabled) - # After makemkv or after handbrake - runAfter: makemkv - # Subtitles? subtitles: True From e01032d2c4d8bd62f119b131f98f745ffc3c43ac Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 17:10:52 +0930 Subject: [PATCH 36/40] misaligned indent --- classes/filebot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index 7bb7222..0795b39 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -65,7 +65,7 @@ def rename(self, dbMovie): return [False] def get_subtitles(self, dbMovie, lang): - command = [ + command = [ 'filebot', '-get-subtitles', dbMovie.path, @@ -103,4 +103,4 @@ def get_subtitles(self, dbMovie, lang): return True else: - return False \ No newline at end of file + return False From 49679d678aa33d60a11e5b37fbfc23c10f7fc666 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 21 Jul 2014 17:19:34 +0930 Subject: [PATCH 37/40] forgot language --- autorip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorip.py b/autorip.py index 984ca6b..a65aced 100644 --- a/autorip.py +++ b/autorip.py @@ -266,7 +266,7 @@ def extras(config): if config['filebot']['subtitles']: log.info( "Grabbing subtitles" ) - status = fb.get_subtitles(dbMovie) + status = fb.get_subtitles(dbMovie, config['filebot']['language']) if status: log.info( "Subtitles downloaded" ) From f824ef1bca42829f1c103168ac70ca98162cd4ac Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 18:27:32 +0930 Subject: [PATCH 38/40] Adding complete message --- autorip.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autorip.py b/autorip.py index a65aced..815f380 100644 --- a/autorip.py +++ b/autorip.py @@ -276,6 +276,8 @@ def extras(config): log.info( "Subtitles not downloaded, no match" ) database.update_movie(dbMovie, 8) + log.info( "Completed work on %s" % dbMovie.moviename ) + else: log.info( "Not grabbing subtitles" ) database.update_movie(dbMovie, 8) From 8db8992f18184338137a05d6b1dceb2937810d8b Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 18:27:51 +0930 Subject: [PATCH 39/40] Moving check to outside if --- classes/filebot.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index 0795b39..5e39bb3 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -58,11 +58,10 @@ def rename(self, dbMovie): if "Done" in line: checks += 1 - if checks >= 3 and renamedMovie: - return [True, renamedMovie] - - else: - return [False] + if checks >= 3 and renamedMovie: + return [True, renamedMovie] + else: + return [False] def get_subtitles(self, dbMovie, lang): command = [ @@ -99,8 +98,7 @@ def get_subtitles(self, dbMovie, lang): if "Done" in line: checks += 1 - if checks >= 2: - return True - - else: - return False + if checks >= 2: + return True + else: + return False From b373e01191d744dc180e81e53f106626b35f046b Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Mon, 21 Jul 2014 18:28:02 +0930 Subject: [PATCH 40/40] Adding stdout read --- classes/filebot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/filebot.py b/classes/filebot.py index 5e39bb3..193c30f 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -86,6 +86,7 @@ def get_subtitles(self, dbMovie, lang): ) checks = 0 + output = proc.stdout.read() if len(output) is not 0: lines = output.split("\n")