diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 65a14d99..ff7cf106 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -205,8 +205,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, result = nzbtomedia.autoProcessMovie().process(sectionName,outputDestination, inputName, status, clientAgent, inputHash, inputCategory) elif sectionName in ['SickBeard','NzbDrone']: + if inputHash: + inputHash = inputHash.upper() result = nzbtomedia.autoProcessTV().processEpisode(sectionName,outputDestination, inputName, status, clientAgent, - inputHash.upper(), inputCategory) + inputHash, inputCategory) elif sectionName == 'HeadPhones': result = nzbtomedia.autoProcessMusic().process(sectionName,outputDestination, inputName, status, clientAgent, inputCategory) elif sectionName == 'Mylar': @@ -220,6 +222,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, logger.error( "A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding") nzbtomedia.resume_torrent(clientAgent, inputHash, inputID, inputName) + else: if clientAgent != 'manual': # update download status in our DB diff --git a/changelog.txt b/changelog.txt index 0887c8ea..8b49ff25 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,15 @@ Change_LOG / History +V10.9 19/01/2015 + +Prevent Errors when trying next release from CouchPotato (CouchPotato failed handling) +Prevent check for status change when using Manage scan (CouchPotato) +Better Tooltip for "host" in NZBGet settings. +Continue if failed to connect to Torrent Client. +Fixed resolution settings in Transcoder. +Make Windows Linking and extraction invisible. + + V10.8 15/12/2014 Impacts All diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index 980dfc17..f75342b1 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -40,6 +40,8 @@ #cpsapikey= # CouchPotato host. +# +# The ipaddress for your CouchPotato server. e.g For the Same system use localhost or 127.0.0.1 #cpshost=localhost # CouchPotato port. diff --git a/nzbToGamez.py b/nzbToGamez.py index a48f7a3d..d85c2961 100755 --- a/nzbToGamez.py +++ b/nzbToGamez.py @@ -36,6 +36,8 @@ #gzapikey= # Gamez host. +# +# The ipaddress for your Gamez server. e.g For the Same system use localhost or 127.0.0.1 #gzhost=localhost # Gamez port. diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index 4d5f0097..9f24faf4 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -35,6 +35,8 @@ #hpapikey= # HeadPhones host. +# +# The ipaddress for your HeadPhones server. e.g For the Same system use localhost or 127.0.0.1 #hphost=localhost # HeadPhones port. diff --git a/nzbToMedia.py b/nzbToMedia.py index 89df7ea9..2f5cd382 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -40,6 +40,8 @@ #cpsapikey= # CouchPotato host. +# +# The ipaddress for your CouchPotato server. e.g For the Same system use localhost or 127.0.0.1 #cpshost=localhost # CouchPotato port. @@ -83,6 +85,8 @@ #sbCategory=tv # SickBeard host. +# +# The ipaddress for your SickBeard/SickRage server. e.g For the Same system use localhost or 127.0.0.1 #sbhost=localhost # SickBeard port. @@ -137,6 +141,8 @@ #ndCategory=tv2 # NzbDrone host. +# +# The ipaddress for your NzbDrone/Sonarr server. e.g For the Same system use localhost or 127.0.0.1 #ndhost=localhost # NzbDrone port. @@ -181,6 +187,8 @@ #hpapikey= # HeadPhones host. +# +# The ipaddress for your HeadPhones server. e.g For the Same system use localhost or 127.0.0.1 #hphost=localhost # HeadPhones port. @@ -209,6 +217,8 @@ #myCategory=comics # Mylar host. +# +# The ipaddress for your Mylar server. e.g For the Same system use localhost or 127.0.0.1 #myhost=localhost # Mylar port. @@ -251,6 +261,8 @@ #gzapikey= # Gamez host. +# +# The ipaddress for your Gamez server. e.g For the Same system use localhost or 127.0.0.1 #gzhost=localhost # Gamez port. diff --git a/nzbToMylar.py b/nzbToMylar.py index fbc8b618..21d7e183 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -33,6 +33,8 @@ #myCategory=comics # Mylar host. +# +# The ipaddress for your Mylar server. e.g For the Same system use localhost or 127.0.0.1 #myhost=localhost # Mylar port. diff --git a/nzbToNzbDrone.py b/nzbToNzbDrone.py index 47f0dcae..caa2703d 100755 --- a/nzbToNzbDrone.py +++ b/nzbToNzbDrone.py @@ -37,6 +37,8 @@ #ndCategory=tv2 # NzbDrone host. +# +# The ipaddress for your NzbDrone/Sonarr server. e.g For the Same system use localhost or 127.0.0.1 #ndhost=localhost # NzbDrone port. diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index cfd77002..d97a29ea 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -42,6 +42,8 @@ #sbCategory=tv # SickBeard host. +# +# The ipaddress for your SickBeard/SickRage server. e.g For the Same system use localhost or 127.0.0.1 #sbhost=localhost # SickBeard port. diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index a103b4ee..f680e100 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -281,7 +281,7 @@ def initialize(section=None): nzbToMediaDB.upgradeDatabase(nzbToMediaDB.DBConnection(), mainDB.InitialSchema) # Set Version and GIT variables - NZBTOMEDIA_VERSION = '10.8' + NZBTOMEDIA_VERSION = '10.9' VERSION_NOTIFY = int(CFG['General']['version_notify']) AUTO_UPDATE = int(CFG['General']['auto_update']) GIT_REPO = 'nzbToMedia' diff --git a/nzbtomedia/autoProcess/autoProcessMovie.py b/nzbtomedia/autoProcess/autoProcessMovie.py index 0bd59092..cf036598 100644 --- a/nzbtomedia/autoProcess/autoProcessMovie.py +++ b/nzbtomedia/autoProcess/autoProcessMovie.py @@ -211,10 +211,6 @@ class autoProcessMovie: video2 = "%s.cp(%s)%s" % (videoName, imdbid, videoExt) logger.debug('Renaming: %s to: %s' % (video, video2)) os.rename(video, video2) - if method == "manage": - command = "/manage.update" - else: - command = "/renamer.scan" params = {} if download_id: @@ -225,6 +221,12 @@ class autoProcessMovie: if remote_path: params['media_folder'] = remoteDir(dirName) + if method == "manage": + command = "/manage.update" + params = {} + else: + command = "/renamer.scan" + url = "%s%s" % (baseURL, command) logger.debug("Opening URL: %s with PARAMS: %s" % (url, params), section) @@ -243,6 +245,8 @@ class autoProcessMovie: return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ] elif result['success']: logger.postprocess("SUCCESS: Finished %s scan for folder %s" % (method, dirName), section) + if method == "manage": + return [0, "%s: Successfully post-processed %s" % (section, inputName) ] else: logger.error("FAILED: %s scan was unable to finish for folder %s. exiting!" % (method, dirName), section) @@ -292,7 +296,7 @@ class autoProcessMovie: logger.debug("Opening URL: %s" % (url), section) try: - r = requests.get(url, params={'media_id': media_id}) + r = requests.get(url, params={'media_id': media_id}, verify=False) except requests.ConnectionError: logger.error("Unable to open URL %s" % (url), section) return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ] diff --git a/nzbtomedia/extractor/bin/invisible.cmd b/nzbtomedia/extractor/bin/invisible.cmd index 09d46c6f..ef1e54ae 100755 --- a/nzbtomedia/extractor/bin/invisible.cmd +++ b/nzbtomedia/extractor/bin/invisible.cmd @@ -1 +1 @@ -start /wait wscript "%~dp0\invisible.vbs" %* \ No newline at end of file +start /B /wait wscript "%~dp0\invisible.vbs" %* \ No newline at end of file diff --git a/nzbtomedia/extractor/extractor.py b/nzbtomedia/extractor/extractor.py index 4f2a7f3b..344903ec 100644 --- a/nzbtomedia/extractor/extractor.py +++ b/nzbtomedia/extractor/extractor.py @@ -97,13 +97,18 @@ def extract(filePath, outputDestination): pwd = os.getcwd() # Get our Present Working Directory os.chdir(outputDestination) # Not all unpack commands accept full paths, so just extract into this directory devnull = open(os.devnull, 'w') + try: # now works same for nt and *nix + info = None cmd.append(filePath) # add filePath to final cmd arg. - if platform.system() != 'Windows': + if platform.system() == 'Windows': + info = subprocess.STARTUPINFO() + info.dwFlags |= subprocess.STARTF_USESHOWWINDOW + else: cmd = nzbtomedia.NICENESS + cmd cmd2 = cmd cmd2.append("-p-") # don't prompt for password. - p = Popen(cmd2, stdout=devnull, stderr=devnull) # should extract files fine. + p = Popen(cmd2, stdout=devnull, stderr=devnull, startupinfo=info) # should extract files fine. res = p.wait() if (res >= 0 and os.name == 'nt') or res == 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful. nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s" % (filePath, outputDestination)) @@ -117,7 +122,7 @@ def extract(filePath, outputDestination): #append password here. passcmd = "-p" + password cmd2.append(passcmd) - p = Popen(cmd2, stdout=devnull, stderr=devnull) # should extract files fine. + p = Popen(cmd2, stdout=devnull, stderr=devnull, startupinfo=info) # should extract files fine. res = p.wait() if (res >= 0 and platform == 'Windows') or res == 0: nzbtomedia.logger.info("EXTRACTOR: Extraction was successful for %s to %s using password: %s" % ( diff --git a/nzbtomedia/linktastic/linktastic.py b/nzbtomedia/linktastic/linktastic.py index 9e5e96ed..408bbc2e 100644 --- a/nzbtomedia/linktastic/linktastic.py +++ b/nzbtomedia/linktastic/linktastic.py @@ -25,6 +25,9 @@ import subprocess from subprocess import CalledProcessError import os +if os.name == 'nt': + info = subprocess.STARTUPINFO() + info.dwFlags |= subprocess.STARTF_USESHOWWINDOW # Prevent spaces from messing with us! def _escape_param(param): @@ -36,7 +39,7 @@ def _link_windows(src, dest): try: subprocess.check_output( 'cmd /C mklink /H %s %s' % (_escape_param(dest), _escape_param(src)), - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, startupinfo=info) except CalledProcessError as err: raise IOError(err.output.decode('utf-8')) @@ -50,7 +53,7 @@ def _symlink_windows(src, dest): try: subprocess.check_output( 'cmd /C mklink %s %s' % (_escape_param(dest), _escape_param(src)), - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, startupinfo=info) except CalledProcessError as err: raise IOError(err.output.decode('utf-8')) @@ -62,7 +65,7 @@ def _dirlink_windows(src, dest): try: subprocess.check_output( 'cmd /C mklink /J %s %s' % (_escape_param(dest), _escape_param(src)), - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, startupinfo=info) except CalledProcessError as err: raise IOError(err.output.decode('utf-8')) @@ -74,7 +77,7 @@ def _junctionlink_windows(src, dest): try: subprocess.check_output( 'cmd /C mklink /D %s %s' % (_escape_param(dest), _escape_param(src)), - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, startupinfo=info) except CalledProcessError as err: raise IOError(err.output.decode('utf-8')) diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 26b0a8fd..16f8e5c9 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -476,7 +476,10 @@ def parse_deluge(args): inputName = args[2] inputHash = args[1] inputID = args[1] - inputCategory = nzbtomedia.TORRENT_CLASS.core.get_torrent_status(inputID, ['label']).get()['label'] + try: + inputCategory = nzbtomedia.TORRENT_CLASS.core.get_torrent_status(inputID, ['label']).get()['label'] + except: + inputCategory = '' return inputDirectory, inputName, inputCategory, inputHash, inputID @@ -734,42 +737,44 @@ def create_torrent_class(clientAgent): def pause_torrent(clientAgent, inputHash, inputID, inputName): logger.debug("Stopping torrent %s in %s while processing" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.stop(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.stop_torrent(inputID) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.pause_torrent([inputID]) - - time.sleep(5) + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.stop(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.stop_torrent(inputID) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.pause_torrent([inputID]) + time.sleep(5) + except: + logger.warning("Failed to stop torrent %s in %s" % (inputName, clientAgent)) def resume_torrent(clientAgent, inputHash, inputID, inputName): logger.debug("Starting torrent %s in %s" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.start(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.start_torrent(inputID) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.resume_torrent([inputID]) - - time.sleep(5) + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.start(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.start_torrent(inputID) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.resume_torrent([inputID]) + time.sleep(5) + except: + logger.warning("Failed to start torrent %s in %s" % (inputName, clientAgent)) def remove_torrent(clientAgent, inputHash, inputID, inputName): if nzbtomedia.DELETE_ORIGINAL == 1 or nzbtomedia.USELINK == 'move': logger.debug("Deleting torrent %s from %s" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.removedata(inputHash) - nzbtomedia.TORRENT_CLASS.remove(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.remove_torrent(inputID, True) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.remove_torrent(inputID, True) - - time.sleep(5) - + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.removedata(inputHash) + nzbtomedia.TORRENT_CLASS.remove(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.remove_torrent(inputID, True) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.remove_torrent(inputID, True) + time.sleep(5) + except: + logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent)) else: resume_torrent(clientAgent, inputHash, inputID, inputName) diff --git a/nzbtomedia/transcoder/transcoder.py b/nzbtomedia/transcoder/transcoder.py index 7005b226..a9206b23 100644 --- a/nzbtomedia/transcoder/transcoder.py +++ b/nzbtomedia/transcoder/transcoder.py @@ -215,14 +215,14 @@ def buildCommands(file, newDir, movieName, bitbucket): if nzbtomedia.VFRAMERATE and not (nzbtomedia.VFRAMERATE * 0.999 <= fr <= nzbtomedia.VFRAMERATE * 1.001): video_cmd.extend(['-r', str(nzbtomedia.VFRAMERATE)]) if scale: - w_scale = width/int(scale.split(':')[0]) - h_scale = height/int(scale.split(':')[1]) + w_scale = width/float(scale.split(':')[0]) + h_scale = height/float(scale.split(':')[1]) if w_scale > h_scale: # widescreen, Scale by width only. - scale = scale.split(':')[0] + ":trunc(ih/2)*2" + scale = scale.split(':')[0] + ":" + str(int((height/w_scale)/2)*2) if w_scale != 1: video_cmd.extend(['-vf', 'scale=' + scale]) else: # lower or mathcing ratio, scale by height only. - scale = "trunc(iw/2)*2:" + scale.split(':')[1] + scale = str(int((width/h_scale)/2)*2) + ":" + scale.split(':')[1] if h_scale != 1: video_cmd.extend(['-vf', 'scale=' + scale]) if nzbtomedia.VBITRATE: