-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from JasonMillward/dev
Fixes #53
- Loading branch information
Showing
10 changed files
with
99 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
|
@@ -52,10 +52,11 @@ | |
import os | ||
import sys | ||
import yaml | ||
import subprocess | ||
from classes import * | ||
from tendo import singleton | ||
|
||
__version__ = "1.6" | ||
__version__ = "1.6.1" | ||
|
||
me = singleton.SingleInstance() | ||
DIR = os.path.dirname(os.path.realpath(__file__)) | ||
|
@@ -212,7 +213,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 | ||
|
@@ -289,6 +290,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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
@@ -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 (rename) 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 (get_subtitles) 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()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
@@ -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 | ||
|
@@ -94,36 +94,36 @@ 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 | ||
# handbrake cli spits out good information into stderr | ||
# so I'll parse stderr as stdout | ||
(results, errors) = proc.communicate() | ||
|
||
if proc.stderr is not None: | ||
output = proc.stderr.read() | ||
if len(output) is not 0: | ||
lines = output.split("\n") | ||
for line in lines: | ||
if proc.returncode is not 0: | ||
self.log.error( | ||
"HandBrakeCLI (compress) 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") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
@@ -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 | ||
|
@@ -144,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 (rip_disc) 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 | ||
|
@@ -192,29 +199,32 @@ def find_disc(self): | |
""" | ||
drives = [] | ||
proc = subprocess.Popen( | ||
['makemkvcon', '-r', 'info'], | ||
['makemkvcon', '-r', 'info', 'disc:-1'], | ||
stderr=subprocess.PIPE, | ||
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 (find_disc) 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.") | ||
|
||
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: | ||
|
@@ -255,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 (get_disc_info) 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" % | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
@license http://opensource.org/licenses/MIT | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters