From bf8fe8261bbcb17b5c81a6d7ae94caedae766bdb Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Sat, 26 Jul 2014 16:54:40 +0930 Subject: [PATCH 01/16] Changing version to dev --- autorippr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autorippr.py b/autorippr.py index e7431d9..1c81201 100644 --- a/autorippr.py +++ b/autorippr.py @@ -53,10 +53,11 @@ import os import sys import yaml +import subprocess from classes import * from tendo import singleton -__version__ = "1.6" +__version__ = "1.6.1-dev" me = singleton.SingleInstance() DIR = os.path.dirname(os.path.realpath(__file__)) From 7a8b05dceaabd5390c2c7d3d184c2ac2ad71c9b6 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Sat, 26 Jul 2014 17:12:51 +0930 Subject: [PATCH 02/16] Adding ability to run commands after filebot completes --- autorippr.py | 9 +++++++++ settings.example.cfg | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/autorippr.py b/autorippr.py index 1c81201..26d7086 100644 --- a/autorippr.py +++ b/autorippr.py @@ -291,6 +291,15 @@ def extras(config): log.info("Completed work on %s" % dbMovie.moviename) + if config['commands'] is not None and len(config['commands']) > 0: + for com in config['commands']: + proc = subprocess.Popen( + [ com ], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + shell=True + ) + else: log.info("Not grabbing subtitles") database.update_movie(dbMovie, 8) diff --git a/settings.example.cfg b/settings.example.cfg index da1cc40..4d02f6f 100644 --- a/settings.example.cfg +++ b/settings.example.cfg @@ -32,3 +32,9 @@ filebot: analytics: enable: True + +commands: + # A list of commands to run after filebot completes + # each line should start with - + # eg: + - mythutil --scanvideos From 9974b3497ecbe250969b1db9f0eac2187094b47c Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Sat, 26 Jul 2014 17:14:29 +0930 Subject: [PATCH 03/16] Cleaning up _t00 from filename --- classes/makemkv.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/makemkv.py b/classes/makemkv.py index c9b8268..4769bb4 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -47,6 +47,8 @@ def _clean_title(self): tmpName = re.sub(r"Disc_(\d)", "", tmpName) + tmpName = tmpName.replace("_t00","") + tmpName = tmpName.replace("\"", "").replace("_", " ") # Clean up the edges and remove whitespace From 99ab132b39d7f6d0be4c763a3c8fecde8cc1d00e Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Wed, 30 Jul 2014 12:35:22 +0930 Subject: [PATCH 04/16] PEP8 cleaning --- classes/makemkv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/makemkv.py b/classes/makemkv.py index 4769bb4..fb56ef6 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -47,7 +47,7 @@ def _clean_title(self): tmpName = re.sub(r"Disc_(\d)", "", tmpName) - tmpName = tmpName.replace("_t00","") + tmpName = tmpName.replace("_t00", "") tmpName = tmpName.replace("\"", "").replace("_", " ") From bfa5de7d8859e876cd7838353b8ac97202fa455f Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Wed, 30 Jul 2014 12:35:57 +0930 Subject: [PATCH 05/16] PEP8 cleaning --- autorippr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorippr.py b/autorippr.py index 26d7086..f2ccfcd 100644 --- a/autorippr.py +++ b/autorippr.py @@ -294,7 +294,7 @@ def extras(config): if config['commands'] is not None and len(config['commands']) > 0: for com in config['commands']: proc = subprocess.Popen( - [ com ], + [com], stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True From cedddd1ebd1cf1fa8ec73125bdcba3625778feae Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Wed, 30 Jul 2014 12:38:12 +0930 Subject: [PATCH 06/16] Fixing pipe stderr to stdout --- classes/handbrake.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index f8316b4..c4828b1 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -94,11 +94,10 @@ def convert(self, nice, args, dbMovie): str(inMovie), '-o', str(outMovie), - args, - '2>&1' + args ], stdout=subprocess.PIPE, - stderr=subprocess.PIPE + stderr=subprocess.STDOUT ) # I'm a little confused here From 876d19b78cedd9853cd3eed5ba448d9d7a0c860f Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Wed, 30 Jul 2014 12:39:54 +0930 Subject: [PATCH 07/16] Using proc.communicate and adding proc.returncode --- classes/handbrake.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/classes/handbrake.py b/classes/handbrake.py index c4828b1..074acba 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -100,29 +100,30 @@ def convert(self, nice, args, dbMovie): stderr=subprocess.STDOUT ) - # I'm a little confused here - # handbrake cli spits out good information into stderr - # 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: + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "HandBrakeCLI returned status code: %d" % proc.returncode) + + if results is not None and len(results) is not 0: + lines = results.split("\n") + for line in lines: + if "Encoding: task" not in line: self.log.debug(line.strip()) - if "average encoding speed for job" in line: - checks += 1 + if "average encoding speed for job" in line: + checks += 1 - if "Encode done!" 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) + if "ERROR" in line and "opening" not in line: + self.log.error( + "HandBrakeCLI encountered the following error: ") + self.log.error(line) - return False + return False if checks >= 2: self.log.debug("HandBrakeCLI Completed successfully") From 4dd8c131e72f7ab54b876dd3e4bf61209777af76 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 31 Jul 2014 10:03:28 +0930 Subject: [PATCH 08/16] Using proc.communicate() instead of stdout.read() --- classes/makemkv.py | 49 +++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/classes/makemkv.py b/classes/makemkv.py index fb56ef6..0b75f97 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -146,16 +146,21 @@ def rip_disc(self, path): stdout=subprocess.PIPE ) - if proc.stderr is not None: - output = proc.stderr.read() - if len(output) is not 0: + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "MakeMKV returned status code: %d" % proc.returncode) + + if errors is not None: + if len(errors) is not 0: self.log.error("MakeMKV encountered the following error: ") - self.log.error(output) + self.log.error(errors) return False checks = 0 - output = proc.stdout.read() - lines = output.split("\n") + + lines = results.split("\n") for line in lines: if "skipped" in line: continue @@ -199,15 +204,19 @@ def find_disc(self): stdout=subprocess.PIPE ) - output = proc.stderr.read() - if proc.stderr is not None: - if len(output) is not 0: + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "MakeMKV returned status code: %d" % proc.returncode) + + if errors is not None: + if len(errors) is not 0: self.log.error("MakeMKV encountered the following error: ") - self.log.error(output) + self.log.error(errors) return [] - output = proc.stdout.read() - if "This application version is too old." in output: + if "This application version is too old." in results: self.log.error("Your MakeMKV version is too old." "Please download the latest version at http://www.makemkv.com" " or enter a registration key to continue using MakeMKV.") @@ -215,8 +224,7 @@ def find_disc(self): return [] # Passed the simple tests, now check for disk drives - - lines = output.split("\n") + lines = results.split("\n") for line in lines: if line[:4] == "DRV:": if "/dev/" in line: @@ -257,11 +265,16 @@ def get_disc_info(self): stderr=subprocess.PIPE ) - output = proc.stderr.read() - if proc.stderr is not None: - if len(output) is not 0: + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "MakeMKV returned status code: %d" % proc.returncode) + + if errors is not None: + if len(errors) is not 0: self.log.error("MakeMKV encountered the following error: ") - self.log.error(output) + self.log.error(errors) return False self.log.debug("MakeMKV found %d titles" % From 45847c5ae8956a35afef9483fa8fa734f5a4577a Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 31 Jul 2014 10:05:16 +0930 Subject: [PATCH 09/16] Using proc.communicate() instead of stdout.read() --- classes/filebot.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index f5c1b03..60ec058 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -46,12 +46,17 @@ def rename(self, dbMovie): stderr=subprocess.PIPE ) - output = proc.stdout.read() + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "Filebot returned status code: %d" % proc.returncode) + renamedMovie = "" checks = 0 - if len(output) is not 0: - lines = output.split("\n") + if len(results) is not 0: + lines = results.split("\n") for line in lines: self.log.debug(line.strip()) if "MOVE" in line: @@ -99,11 +104,16 @@ def get_subtitles(self, dbMovie, lang): stderr=subprocess.PIPE ) + (results, errors) = proc.communicate() + + if proc.returncode is not 0: + self.log.error( + "Filebot returned status code: %d" % proc.returncode) + checks = 0 - output = proc.stdout.read() - if len(output) is not 0: - lines = output.split("\n") + if len(results) is not 0: + lines = results.split("\n") for line in lines: self.log.debug(line.strip()) From f96d893bf09591f4941bf9bdbe00447fdb77c87a Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 31 Jul 2014 10:12:03 +0930 Subject: [PATCH 10/16] Adding clarification to error log --- classes/makemkv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/makemkv.py b/classes/makemkv.py index 0b75f97..109ba46 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -150,7 +150,7 @@ def rip_disc(self, path): if proc.returncode is not 0: self.log.error( - "MakeMKV returned status code: %d" % proc.returncode) + "MakeMKV (rip_disc) returned status code: %d" % proc.returncode) if errors is not None: if len(errors) is not 0: @@ -208,7 +208,7 @@ def find_disc(self): if proc.returncode is not 0: self.log.error( - "MakeMKV returned status code: %d" % proc.returncode) + "MakeMKV (find_disc) returned status code: %d" % proc.returncode) if errors is not None: if len(errors) is not 0: @@ -269,7 +269,7 @@ def get_disc_info(self): if proc.returncode is not 0: self.log.error( - "MakeMKV returned status code: %d" % proc.returncode) + "MakeMKV (get_disc_info) returned status code: %d" % proc.returncode) if errors is not None: if len(errors) is not 0: From 4116402ba98641c0b8305c71606cad0ca862269e Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 31 Jul 2014 10:12:10 +0930 Subject: [PATCH 11/16] Adding clarification to error log --- classes/filebot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/filebot.py b/classes/filebot.py index 60ec058..563a7d0 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -50,7 +50,7 @@ def rename(self, dbMovie): if proc.returncode is not 0: self.log.error( - "Filebot returned status code: %d" % proc.returncode) + "Filebot (rename) returned status code: %d" % proc.returncode) renamedMovie = "" checks = 0 @@ -108,7 +108,7 @@ def get_subtitles(self, dbMovie, lang): if proc.returncode is not 0: self.log.error( - "Filebot returned status code: %d" % proc.returncode) + "Filebot (get_subtitles) returned status code: %d" % proc.returncode) checks = 0 From ed7babeaf214496dc3edc407af82c688e130216b Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 31 Jul 2014 10:12:59 +0930 Subject: [PATCH 12/16] Changing function convert to compress Because no conversion is done --- autorippr.py | 2 +- classes/handbrake.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autorippr.py b/autorippr.py index f2ccfcd..929b7ef 100644 --- a/autorippr.py +++ b/autorippr.py @@ -214,7 +214,7 @@ def compress(config): log.info("Compressing %s" % dbMovie.moviename) with stopwatch.stopwatch() as t: - status = hb.convert( + status = hb.compress( args=config['handbrake']['com'], nice=int(config['handbrake']['nice']), dbMovie=dbMovie diff --git a/classes/handbrake.py b/classes/handbrake.py index 074acba..29e59eb 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -58,7 +58,7 @@ def check_exists(self, dbMovie): self.log.error("Input file no longer exists") return False - def convert(self, nice, args, dbMovie): + def compress(self, nice, args, dbMovie): """ Passes the nessesary parameters to HandBrake to start an encoding Assigns a nice value to allow give normal system tasks priority @@ -104,7 +104,7 @@ def convert(self, nice, args, dbMovie): if proc.returncode is not 0: self.log.error( - "HandBrakeCLI returned status code: %d" % proc.returncode) + "HandBrakeCLI (compress) returned status code: %d" % proc.returncode) if results is not None and len(results) is not 0: lines = results.split("\n") From 0e38510fa1487d0543feb8bf7953fef02de43684 Mon Sep 17 00:00:00 2001 From: Jason Millward Date: Thu, 31 Jul 2014 11:30:25 +0930 Subject: [PATCH 13/16] Fixing makemkvcon call, adding disc:-1 --- classes/makemkv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/makemkv.py b/classes/makemkv.py index 109ba46..04aa00b 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -199,7 +199,7 @@ def find_disc(self): """ drives = [] proc = subprocess.Popen( - ['makemkvcon', '-r', 'info'], + ['makemkvcon', '-r', 'info', 'disc:-1'], stderr=subprocess.PIPE, stdout=subprocess.PIPE ) From 716126f35f410a2f4c2241dcfa6166cb0889bb82 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 18 Aug 2014 10:41:16 +0930 Subject: [PATCH 14/16] Updating version --- autorippr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorippr.py b/autorippr.py index 929b7ef..8c22785 100644 --- a/autorippr.py +++ b/autorippr.py @@ -57,7 +57,7 @@ from classes import * from tendo import singleton -__version__ = "1.6.1-dev" +__version__ = "1.6.1" me = singleton.SingleInstance() DIR = os.path.dirname(os.path.realpath(__file__)) From efdb3f9ff2203478d0bc7b6a30b18c9fee815a39 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 18 Aug 2014 10:41:39 +0930 Subject: [PATCH 15/16] Turning off mythutil by default --- settings.example.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.example.cfg b/settings.example.cfg index 4d02f6f..caafbd5 100644 --- a/settings.example.cfg +++ b/settings.example.cfg @@ -18,6 +18,7 @@ handbrake: nice: 15 # The HandBrake command line options and arguments + # Configure this to change output quality com: --x264-preset=medium --two-pass --turbo -s 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 filebot: @@ -37,4 +38,4 @@ commands: # A list of commands to run after filebot completes # each line should start with - # eg: - - mythutil --scanvideos + # - mythutil --scanvideos From a70aaf0be9fe8c1034b7bddd1830d66ccfc89d00 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 18 Aug 2014 10:43:21 +0930 Subject: [PATCH 16/16] Updating docblock versions --- autorippr.py | 2 +- classes/analytics.py | 2 +- classes/database.py | 2 +- classes/filebot.py | 2 +- classes/handbrake.py | 2 +- classes/logger.py | 2 +- classes/makemkv.py | 2 +- classes/stopwatch.py | 2 +- classes/testing.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autorippr.py b/autorippr.py index 8c22785..1d6e081 100644 --- a/autorippr.py +++ b/autorippr.py @@ -28,7 +28,7 @@ Copyright (c) 2014, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT diff --git a/classes/analytics.py b/classes/analytics.py index 7ff287f..cce7b60 100644 --- a/classes/analytics.py +++ b/classes/analytics.py @@ -20,7 +20,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/database.py b/classes/database.py index ceb3c8f..39dc5fc 100644 --- a/classes/database.py +++ b/classes/database.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/filebot.py b/classes/filebot.py index 563a7d0..1286060 100644 --- a/classes/filebot.py +++ b/classes/filebot.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/handbrake.py b/classes/handbrake.py index 29e59eb..6df8cff 100644 --- a/classes/handbrake.py +++ b/classes/handbrake.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/logger.py b/classes/logger.py index be0ad42..4b22809 100644 --- a/classes/logger.py +++ b/classes/logger.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/makemkv.py b/classes/makemkv.py index 04aa00b..26e3b42 100644 --- a/classes/makemkv.py +++ b/classes/makemkv.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/stopwatch.py b/classes/stopwatch.py index aaf0052..8bd96fd 100644 --- a/classes/stopwatch.py +++ b/classes/stopwatch.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """ diff --git a/classes/testing.py b/classes/testing.py index cae37d6..f02abd2 100644 --- a/classes/testing.py +++ b/classes/testing.py @@ -6,7 +6,7 @@ Copyright (c) 2012, Jason Millward @category misc -@version $Id: 1.6, 2014-07-21 18:48:00 CST $; +@version $Id: 1.6.1, 2014-08-18 10:42:00 CST $; @author Jason Millward @license http://opensource.org/licenses/MIT """