From 78f92ad700cc2b5ec7067eb659736b7e181bfa95 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 5 Mar 2014 21:27:23 +1030 Subject: [PATCH 01/24] next dev version --- autoProcess/nzbToMediaEnv.py | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index 89bf99dd..ed3f256a 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -1,7 +1,7 @@ # Make things easy and less error prone by centralising all common values # Global Constants -VERSION = 'V9.2' +VERSION = 'V9.3' TimeOut = 60 # Constants pertinant to SabNzb diff --git a/changelog.txt b/changelog.txt index 25d3298c..e2864fa1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ Change_LOG / History +V9.3 XX/XX/2014 + + + V9.2 05/03/2014 Impacts All From fc451f054d447c1df50a2ef03476a7a8bd5e4047 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 12 Mar 2014 10:37:15 +1030 Subject: [PATCH 02/24] allow headphones to remove torrent. fixes #279 --- TorrentToMedia.py | 9 +++------ changelog.txt | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 8b65b14d..7ed73e32 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -314,6 +314,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): except: Logger.exception("MAIN: Failed to move file: %s", file) continue + shutil.rmtree(outputDestination) # Hardlink solution for uTorrent, need to implent support for deluge, transmission if clientAgent in ['utorrent', 'transmission', 'deluge'] and inputHash: @@ -322,13 +323,9 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): Logger.debug("MAIN: Deleting torrent %s from %s", inputName, clientAgent) if clientAgent == 'utorrent' and utorrentClass != "": utorrentClass.removedata(inputHash) - if not inputCategory in hpCategory: - utorrentClass.remove(inputHash) + utorrentClass.remove(inputHash) if clientAgent == 'transmission' and TransmissionClass !="": - if inputCategory in hpCategory: #don't delete actual files for hp category, just remove torrent. - TransmissionClass.remove_torrent(inputID, False) - else: - TransmissionClass.remove_torrent(inputID, True) + TransmissionClass.remove_torrent(inputID, True) if clientAgent == 'deluge' and delugeClient != "": delugeClient.core.remove_torrent(inputID, True) # we always want to resume seeding, for now manually find out what is wrong when extraction fails diff --git a/changelog.txt b/changelog.txt index e2864fa1..f80d8b38 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,8 @@ Change_LOG / History V9.3 XX/XX/2014 - +Impacts Torrents +Allow Headphones to remove torrents and data after processing. V9.2 05/03/2014 From 008fd81db945058edcf527ae2708ea7dada69e2c Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 12 Mar 2014 10:46:09 +1030 Subject: [PATCH 03/24] delete torrent if uselink = move. --- TorrentToMedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 7ed73e32..096f257b 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -319,7 +319,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): # Hardlink solution for uTorrent, need to implent support for deluge, transmission if clientAgent in ['utorrent', 'transmission', 'deluge'] and inputHash: # Delete torrent and torrentdata from Torrent client if processing was successful. - if deleteOriginal == 1 and result != 1: + if (deleteOriginal == 1 and result != 1) or useLink == 'move': # added uselink = move, if we move files, nothing to resume seeding. Logger.debug("MAIN: Deleting torrent %s from %s", inputName, clientAgent) if clientAgent == 'utorrent' and utorrentClass != "": utorrentClass.removedata(inputHash) From cd8607e42e084080a1a05397c30026fbb8aa5e09 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 12 Mar 2014 10:47:15 +1030 Subject: [PATCH 04/24] add changenotes. --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index f80d8b38..1c32c18e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ V9.3 XX/XX/2014 Impacts Torrents Allow Headphones to remove torrents and data after processing. +Delete torrent if uselink = move V9.2 05/03/2014 From a1f659e21e323857c61addd79fd7f63389a36bca Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Thu, 13 Mar 2014 14:04:26 +1030 Subject: [PATCH 05/24] added forceClean for outputDirectory. --- TorrentToMedia.py | 3 ++- autoProcess/autoProcessMovie.py | 4 +++- autoProcessMedia.cfg.sample | 1 + changelog.txt | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 096f257b..95e99ef1 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -349,7 +349,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): if fileExtension in mediaContainer or fileExtension in metaContainer: num_files_new = num_files_new + 1 file_list.append(file) - if num_files_new == int(0): + if num_files_new == int(0) or forceClean == 1: Logger.info("All files have been processed. Cleaning outputDirectory %s", outputDestination) shutil.rmtree(outputDestination) else: @@ -479,6 +479,7 @@ if __name__ == "__main__": DelugePWD = config.get("Torrent", "DelugePWD") # mysecretpwr deleteOriginal = int(config.get("Torrent", "deleteOriginal")) # 0 + forceClean = int(config.get("Torrent", "forceClean")) # 0 compressedContainer = (config.get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 2adbc78e..7c70e66b 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -337,8 +337,10 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id Logger.exception("Unable to delete folder %s", dirName) return 0 # success - if nzbName == "Manual Run" or download_id == "none": + if nzbName == "Manual Run": return 0 # success + if download_id == "none": + return 1 # just to be sure TorrentToMedia doesn't start deleting files as we havent verified changed status. # we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing. socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout. diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 3270cbee..42583ff8 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -105,6 +105,7 @@ DelugeUSR = your username DelugePWD = your password ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ###### deleteOriginal = 0 +forceClean = 0 [Extensions] compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001 diff --git a/changelog.txt b/changelog.txt index 1c32c18e..534e7ed6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ V9.3 XX/XX/2014 Impacts Torrents Allow Headphones to remove torrents and data after processing. Delete torrent if uselink = move +Added forceClean for outputDir. Works in file permissions prevent CP/SB from moving files. V9.2 05/03/2014 From ec6129cb368ed14deaf6a5d359ee8fcad798bccc Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Thu, 13 Mar 2014 22:36:53 +1030 Subject: [PATCH 06/24] check for .x264 in archive parts. fixes #281 --- TorrentToMedia.py | 2 +- changelog.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 95e99ef1..731be4bf 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -208,7 +208,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): except: Logger.exception("MAIN: Failed to link file: %s", file) # find part numbers in second "extension" from right, if we have more than 1 compressed file in the same directory. - if re.search(r'\d+', os.path.splitext(fileName)[1]) and os.path.dirname(filePath) in extracted_folder and not (os.path.splitext(fileName)[1] in ['.720p','.1080p']): + if re.search(r'\d+', os.path.splitext(fileName)[1]) and os.path.dirname(filePath) in extracted_folder and not any(item in os.path.splitext(fileName)[1] for item in ['.720p','.1080p','.x264']): part = int(re.search(r'\d+', os.path.splitext(fileName)[1]).group()) if part == 1: # we only want to extract the primary part. Logger.debug("MAIN: Found primary part of a multi-part archive %s. Extracting", file) diff --git a/changelog.txt b/changelog.txt index 534e7ed6..4d3cbc78 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Impacts Torrents Allow Headphones to remove torrents and data after processing. Delete torrent if uselink = move Added forceClean for outputDir. Works in file permissions prevent CP/SB from moving files. +Ignore .x264 from archive "part" checks. V9.2 05/03/2014 From c2f10b832cb95eb3e46845129c4921f73d6c13a0 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 14 Mar 2014 12:06:09 +1030 Subject: [PATCH 07/24] fix setting of Mylar config from NZBGet. --- autoProcess/migratecfg.py | 2 +- changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index e4389702..78cfe58a 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -328,7 +328,7 @@ def addnzbget(): envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT'] cfgKeys = ['mlCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root'] for index in range(len(envKeys)): - key = 'NZBPO_ML' + envKeys[index] + key = 'NZBPO_MY' + envKeys[index] if os.environ.has_key(key): option = cfgKeys[index] value = os.environ[key] diff --git a/changelog.txt b/changelog.txt index 4d3cbc78..e0e26f4a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,9 @@ Delete torrent if uselink = move Added forceClean for outputDir. Works in file permissions prevent CP/SB from moving files. Ignore .x264 from archive "part" checks. +Impacts NZBs +Fix setting of Mylar config from NZBGet. + V9.2 05/03/2014 Impacts All From 0a9c8030e5c00b6ec81bd3f0516ac0b94a9f4ac3 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 18 Mar 2014 16:20:59 +1030 Subject: [PATCH 08/24] new api call for CouchPotato --- autoProcess/autoProcessMovie.py | 164 ++++++++++++-------------------- changelog.txt | 3 + 2 files changed, 62 insertions(+), 105 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 7c70e66b..13795b33 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -1,4 +1,4 @@ -import sys +uimport sys import urllib import os import shutil @@ -44,14 +44,19 @@ def get_imdb(nzbName, dirName): return "" def get_movie_info(baseURL, imdbid, download_id): - - if not imdbid and not download_id: - return "", None, imdbid movie_id = "" + + if not imdbid and not download_id: + return movie_id, imdbid, download_id, None, None + releaselist = [] movieid = [] + moviestatus = [] library = [] + release = [] + movie_status = None + release_status = None offset = int(0) while True: url = baseURL + "media.list/?status=active&release_status=snatched&limit_offset=50," + str(offset) @@ -66,59 +71,65 @@ def get_movie_info(baseURL, imdbid, download_id): movieid2 = [] library2 = [] + release2 = [] + moviestatus2 = [] try: result = json.load(urlObj) - movieid2 = [item["id"] for item in result["movies"]] - library2 = [item["library"]["identifier"] for item in result["movies"]] + movieid2 = [item["_id"] for item in result["movies"]] + library2 = [item["identifier"] for item in result["movies"]] + release2 = [item["releases"] for item in result["movies"]] + moviestatus2 = [item["status"] for item in result["movies"]] except: Logger.exception("Unable to parse json data for movies") break movieid.extend(movieid2) + moviestatus.extend(moviestatus2) library.extend(library2) + release.extend(release2) if len(movieid2) < int(50): # finished parsing list of movies. Time to break. break offset = offset + 50 result = None # reset for index in range(len(movieid)): - if not imdbid: - url = baseURL + "media.get/?id=" + str(movieid[index]) - Logger.debug("Opening URL: %s", url) - try: - urlObj = urllib.urlopen(url) - except: - Logger.exception("Unable to open URL") - return "", None, imdbid - try: - result = json.load(urlObj) - releaselist = [item["info"]["download_id"] for item in result["media"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower()] - except: - Logger.exception("Unable to parse json data for releases") - return "", None, imdbid + releaselist1 = [item for item in release[index] if item["status"] == "snatched" and "download_info" in item] + if download_id: + releaselist = [item for item in releaselist1 if item["download_info"]["id"].lower() == download_id.lower()] + else: + releaselist = releaselist1 - if len(releaselist) > 0: - movie_id = str(movieid[index]) - imdbid = str(library[index]) - Logger.info("Found movie id %s and imdb %s in database via download_id %s", movie_id, imdbid, download_id) - break - else: - continue - - if library[index] == imdbid: + if imdbid and library[index] == imdbid: movie_id = str(movieid[index]) - Logger.info("Found movie id %s in CPS database for movie %s", movie_id, imdbid) - break + movie_status = str(moviestatus[index]) + Logger.info("Found movie id %s with status %s in CPS database for movie %s", movie_id, movie_status, imdbid) + if not download_id and len(releaselist) == 1: + download_id = releaselist[0]["download_info"]["id"] + elif not imdbid and download_id and len(releaselist) > 0: + movie_id = str(movieid[index]) + movie_status = str(moviestatus[index]) + imdbid = str(library[index]) + Logger.info("Found movie id %s and imdb %s with status %s in CPS database via download_id %s", movie_id, imdbid, movie_status, download_id) + + else: + continue + + if len(releaselist) == 1: + Logger.debug("Found a single release with download_id: %s. Release status is: %s", download_id, release_status) + release_status = releaselist[0]["status"] + + break + if not movie_id: Logger.exception("Could not parse database results to determine imdbid or movie id") - return movie_id, result, imdbid + return movie_id, imdbid, download_id, movie_status, release_status -def get_status(baseURL, movie_id, clientAgent, download_id, result=None): +def get_status(baseURL, movie_id, download_id): if not movie_id: - return "", clientAgent, "none", "none" + return None, None Logger.debug("Looking for status of movie: %s - with release sent to clientAgent: %s and download_id: %s", movie_id, clientAgent, download_id) if not result: # we haven't already called media.get @@ -129,71 +140,18 @@ def get_status(baseURL, movie_id, clientAgent, download_id, result=None): urlObj = urllib.urlopen(url) except: Logger.exception("Unable to open URL") - return "", clientAgent, "none", "none" - result = json.load(urlObj) + return None, None try: - movie_status = result["media"]["status"]["identifier"] + result = json.load(urlObj) + movie_status = str(result["media"]["status"]) + release_status = None # for now... keep this as a place holder. Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status) except: # index out of range/doesn't exist? Logger.exception("Could not find a status for this movie") - movie_status = "" - try: - release_status = "none" - if download_id != "" and download_id != "none": # we have the download id from the downloader. Let's see if it's valid. - release_statuslist = [item["status"]["identifier"] for item in result["media"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower()] - clientAgentlist = [item["info"]["download_downloader"] for item in result["media"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower()] - if len(release_statuslist) == 1: # we have found a release by this id. :) - release_status = release_statuslist[0] - clientAgent = clientAgentlist[0] - Logger.debug("Found a single release with download_id: %s for clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) - return movie_status, clientAgent, download_id, release_status - elif len(release_statuslist) > 1: # we have found many releases by this id. Check for snatched status - clients = [item for item in clientAgentlist if item.lower() == clientAgent.lower()] - clientAgent = clients[0] - if len(clients) == 1: # ok.. a unique entry for download_id and clientAgent ;) - release_status = [item["status"]["identifier"] for item in result["media"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower() and item["info"]["download_downloader"] == clientAgent][0] - Logger.debug("Found a single release for download_id: %s and clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) - else: # doesn't matter. only really used as secondary confirmation of movie status change. Let's continue. - Logger.debug("Found several releases for download_id: %s and clientAgent: %s. Cannot determine the release status", download_id, clientAgent) - return movie_status, clientAgent, download_id, release_status - else: # clearly the id we were passed doesn't match the database. Reset it and search all snatched releases.... hence the next if (not elif ;) ) - download_id = "" - if download_id == "none": # if we couldn't find this initially, there is no need to check next time around. - return movie_status, clientAgent, download_id, release_status - elif download_id == "": # in case we didn't get this from the downloader. - download_idlist = [item["info"]["download_id"] for item in result["media"]["releases"] if item["status"]["identifier"] == "snatched"] - clientAgentlist = [item["info"]["download_downloader"] for item in result["media"]["releases"] if item["status"]["identifier"] == "snatched"] - if len(clientAgentlist) == 1: - if clientAgent == "manual": - clientAgent = clientAgentlist[0] - download_id = download_idlist[0] - release_status = "snatched" - elif clientAgent.lower() == clientAgentlist[0].lower(): - download_id = download_idlist[0] - clientAgent = clientAgentlist[0] - release_status = "snatched" - Logger.debug("Found a single download_id: %s and clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) - elif clientAgent == "manual": - download_id = "none" - release_status = "none" - else: - index = [index for index in range(len(clientAgentlist)) if clientAgentlist[index].lower() == clientAgent.lower()] - if len(index) == 1: - download_id = download_idlist[index[0]] - clientAgent = clientAgentlist[index[0]] - release_status = "snatched" - Logger.debug("Found download_id: %s for clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) - else: - Logger.info("Found a total of %s releases snatched for clientAgent: %s. Cannot determine download_id. Will perform a renamenr scan to try and process.", len(index), clientAgent) - download_id = "none" - release_status = "none" - else: #something went wrong here.... we should never get to this. - Logger.info("Could not find a download_id in the database for this movie") - release_status = "none" - except: # index out of range/doesn't exist? - Logger.exception("Could not find a download_id for this movie") - download_id = "none" - return movie_status, clientAgent, download_id, release_status + movie_status = None + release_status = None + + return movie_status, release_status def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id = "", inputCategory=None): @@ -254,9 +212,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id baseURL = protocol + host + ":" + port + web_root + "/api/" + apikey + "/" - movie_id, result, imdbid = get_movie_info(baseURL, imdbid, download_id) # get the CPS database movie id for this movie. - - initial_status, clientAgent, download_id, initial_release_status = get_status(baseURL, movie_id, clientAgent, download_id, result) + movie_id, imdbid, download_id, initial_status, initial_release_status = get_movie_info(baseURL, imdbid, download_id) # get the CPS database movie id for this movie. process_all_exceptions(nzbName.lower(), dirName) nzbName, dirName = converto_to_ascii(nzbName, dirName) @@ -276,7 +232,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id command = "manage.update" else: command = "renamer.scan" - if clientAgent != "manual" and download_id != "none": + if clientAgent != "manual" and download_id != None: if remoteCPS == 1: command = command + "/?downloader=" + clientAgent + "&download_id=" + download_id else: @@ -337,10 +293,8 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id Logger.exception("Unable to delete folder %s", dirName) return 0 # success - if nzbName == "Manual Run": + if nzbName == "Manual Run" or download_id == "none": return 0 # success - if download_id == "none": - return 1 # just to be sure TorrentToMedia doesn't start deleting files as we havent verified changed status. # we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing. socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout. @@ -348,13 +302,13 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id start = datetime.datetime.now() # set time for timeout pause_for = int(wait_for) * 10 # keep this so we only ever have 6 complete loops. This may not be necessary now? while (datetime.datetime.now() - start) < datetime.timedelta(minutes=wait_for): # only wait 2 (default) minutes, then return. - movie_status, clientAgent, download_id, release_status = get_status(baseURL, movie_id, clientAgent, download_id) # get the current status fo this movie. - if movie_status != initial_status: # Something has changed. CPS must have processed this movie. + movie_status, release_status = get_status(baseURL, movie_id, download_id) # get the current status fo this movie. + if movie_status and initial_status and movie_status != initial_status: # Something has changed. CPS must have processed this movie. Logger.info("SUCCESS: This movie is now marked as status %s in CouchPotatoServer", movie_status) return 0 # success time.sleep(pause_for) # Just stop this looping infinitely and hogging resources for 2 minutes ;) else: - if release_status != initial_release_status and release_status != "none": # Something has changed. CPS must have processed this movie. + if release_status and initial_release_status and release_status != initial_release_status: # Something has changed. CPS must have processed this movie. Logger.info("SUCCESS: This release is now marked as status %s in CouchPotatoServer", release_status) return 0 # success else: # The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resule seeding now. diff --git a/changelog.txt b/changelog.txt index e0e26f4a..995e3e7d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,6 +11,9 @@ Ignore .x264 from archive "part" checks. Impacts NZBs Fix setting of Mylar config from NZBGet. +Impacts All +Changes to Couchpotato API for [nosql] added. Keeps aligned with current CouchPotato develop branch. + V9.2 05/03/2014 Impacts All From 4d69f85677b32b64c8031040adcc85030a688337 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 18 Mar 2014 16:42:28 +1030 Subject: [PATCH 09/24] a few small fixes --- autoProcess/autoProcessMovie.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 13795b33..9aab0fd8 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -1,4 +1,4 @@ -uimport sys +import sys import urllib import os import shutil @@ -46,17 +46,16 @@ def get_imdb(nzbName, dirName): def get_movie_info(baseURL, imdbid, download_id): movie_id = "" - + movie_status = None + release_status = None if not imdbid and not download_id: - return movie_id, imdbid, download_id, None, None + return movie_id, imdbid, download_id, movie_status, release_status releaselist = [] movieid = [] moviestatus = [] library = [] release = [] - movie_status = None - release_status = None offset = int(0) while True: url = baseURL + "media.list/?status=active&release_status=snatched&limit_offset=50," + str(offset) @@ -293,8 +292,10 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id Logger.exception("Unable to delete folder %s", dirName) return 0 # success - if nzbName == "Manual Run" or download_id == "none": + if nzbName == "Manual Run": return 0 # success + if not download_id: + return 1 # just to be sure TorrentToMedia doesn't start deleting files as we havent verified changed status. # we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing. socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout. From 7f8ded9f0e5670e8ef65d46c940a5100d396f058 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 18 Mar 2014 19:59:02 +1030 Subject: [PATCH 10/24] more minor fixes --- autoProcess/autoProcessMovie.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 9aab0fd8..e662cf8d 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -115,8 +115,8 @@ def get_movie_info(baseURL, imdbid, download_id): continue if len(releaselist) == 1: - Logger.debug("Found a single release with download_id: %s. Release status is: %s", download_id, release_status) release_status = releaselist[0]["status"] + Logger.debug("Found a single release with download_id: %s. Release status is: %s", download_id, release_status) break @@ -130,7 +130,7 @@ def get_status(baseURL, movie_id, download_id): if not movie_id: return None, None - Logger.debug("Looking for status of movie: %s - with release sent to clientAgent: %s and download_id: %s", movie_id, clientAgent, download_id) + Logger.debug("Looking for status of movie: %s", movie_id) if not result: # we haven't already called media.get url = baseURL + "media.get/?id=" + str(movie_id) Logger.debug("Opening URL: %s", url) From 21fc2f921774bb08e61a33475e3d484aaa327035 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 19 Mar 2014 07:10:18 +1030 Subject: [PATCH 11/24] remove obsolete test --- autoProcess/autoProcessMovie.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index e662cf8d..76b78461 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -131,15 +131,14 @@ def get_status(baseURL, movie_id, download_id): return None, None Logger.debug("Looking for status of movie: %s", movie_id) - if not result: # we haven't already called media.get - url = baseURL + "media.get/?id=" + str(movie_id) - Logger.debug("Opening URL: %s", url) + url = baseURL + "media.get/?id=" + str(movie_id) + Logger.debug("Opening URL: %s", url) - try: - urlObj = urllib.urlopen(url) - except: - Logger.exception("Unable to open URL") - return None, None + try: + urlObj = urllib.urlopen(url) + except: + Logger.exception("Unable to open URL") + return None, None try: result = json.load(urlObj) movie_status = str(result["media"]["status"]) From a9556dd7a023bbd39b08222f37a598dff9be28ca Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 21 Mar 2014 21:55:00 +1030 Subject: [PATCH 12/24] cleanup and a few fixes. #288 --- TorrentToMedia.py | 5 +++-- autoSickBeardFork.py => autoProcess/autoSickBeardFork.py | 6 +++--- autoProcess/migratecfg.py | 2 ++ nzbToMedia.py | 2 +- nzbToSickBeard.py | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) rename autoSickBeardFork.py => autoProcess/autoSickBeardFork.py (90%) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index ccb71b30..692fdeab 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -21,7 +21,7 @@ import autoProcess.autoProcessMovie as autoProcessMovie import autoProcess.autoProcessTV as autoProcessTV from autoProcess.nzbToMediaEnv import * from autoProcess.nzbToMediaUtil import * -from autoSickBeardFork import autoFork +from autoProcess.autoSickBeardFork import autoFork from utorrent.client import UTorrentClient from transmissionrpc.client import Client as TransmissionClient from synchronousdeluge.client import DelugeClient @@ -44,6 +44,8 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory) + sbFork, sbParams = autoFork() + if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT and Torrent_ForceLink != 1: Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",sbFork ,inputName) result = autoProcessTV.processEpisode(inputDirectory, inputName, int(0)) @@ -490,7 +492,6 @@ if __name__ == "__main__": cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv - sbFork, sbParams = autoFork(config.get("SickBeard", "fork")) # default Torrent_ForceLink = int(config.get("SickBeard", "Torrent_ForceLink")) # 1 hpCategory = (config.get("HeadPhones", "hpCategory")).split(',') # music mlCategory = (config.get("Mylar", "mlCategory")).split(',') # comics diff --git a/autoSickBeardFork.py b/autoProcess/autoSickBeardFork.py similarity index 90% rename from autoSickBeardFork.py rename to autoProcess/autoSickBeardFork.py index bfaef381..bbaaf405 100644 --- a/autoSickBeardFork.py +++ b/autoProcess/autoSickBeardFork.py @@ -51,10 +51,10 @@ def autoFork(fork=None): try: fork = config.get(section, "fork") if not fork in "auto": - fork = forks[fork] \ - if fork in SICKBEARD_FAILED or SICKBEARD_TORRENT else forks[fork_default] + fork = fork if fork in SICKBEARD_FAILED or fork in SICKBEARD_TORRENT else fork_default + fork = [f for f in forks.iteritems() if f[0] == fork][0] except ConfigParser.NoOptionError: - fork = forks[fork_default] + fork = [f for f in forks.iteritems() if f[0] == fork_default][0] myOpener = AuthURLOpener(username, password) diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index fc17680c..ff639fc6 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -61,6 +61,8 @@ def migrate(): if option == "failed_fork": # change this old format option = "fork" value = "auto" + if option == "fork" and value in ["TPB", "TPB-failed", "Pistachitos"]: # Merge all these to "auto" + value = "auto" if option == "outputDirectory": # move this to new location format value = os.path.split(os.path.normpath(value))[0] confignew.set("Torrent", option, value) diff --git a/nzbToMedia.py b/nzbToMedia.py index e7db98af..1a50a5e3 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -109,7 +109,7 @@ # SickBeard fork. # -# set to default or auto to auto-detect the custom failed fork type". +# set to default or auto to auto-detect the custom fork type. #sbfork=auto # SickBeard Delete Failed Downloads (0, 1) diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 70ba9b79..1c554fe1 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -58,8 +58,8 @@ # SickBeard fork. # -# set to default or TPB or failed if using the custom "TPB" or "failed fork". -#sbfork=default +# set to default or auto to auto-detect the custom fork type. +#sbfork=auto # SickBeard Delete Failed Downloads (0, 1). # From 40be374b0f1e3e8c78ab9dfade754eff87fd4fed Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 21 Mar 2014 21:56:58 +1030 Subject: [PATCH 13/24] update changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 995e3e7d..c221969a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -13,6 +13,7 @@ Fix setting of Mylar config from NZBGet. Impacts All Changes to Couchpotato API for [nosql] added. Keeps aligned with current CouchPotato develop branch. +Add Auto Detection of SickBeard Fork. V9.2 05/03/2014 From 59264f55ad176c9ec5cd5f494a9cd8a66ec8a15f Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 21 Mar 2014 22:06:08 +1030 Subject: [PATCH 14/24] remove my version. #289 --- autoProcess/migratecfg.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index 0042a2cc..1e74fe91 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -64,8 +64,6 @@ def migrate(): value = "auto" if option == "fork" and value not in ["default", "failed", "failed-torrent", "auto"]: value = "auto" - if option == "fork" and value in ["TPB", "TPB-failed", "Pistachitos"]: # Merge all these to "auto" - value = "auto" if option == "outputDirectory": # move this to new location format value = os.path.split(os.path.normpath(value))[0] confignew.set("Torrent", option, value) From efe4804d991de55f9d5eb17abe321ca0616fef32 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 07:30:17 +1030 Subject: [PATCH 15/24] change failed url to media_id --- autoProcess/autoProcessMovie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 76b78461..961bfc32 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -268,7 +268,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id Logger.error("Exiting autoProcessMovie script") return 1 # failure - url = baseURL + "movie.searcher.try_next/?id=" + movie_id + url = baseURL + "movie.searcher.try_next/?media_id=" + movie_id Logger.debug("Opening URL: %s", url) From d41424725937e3ef058edf6a57cef24109843564 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 10:22:04 +1030 Subject: [PATCH 16/24] fix release status check --- autoProcess/autoProcessMovie.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 961bfc32..be633ebb 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -142,8 +142,8 @@ def get_status(baseURL, movie_id, download_id): try: result = json.load(urlObj) movie_status = str(result["media"]["status"]) - release_status = None # for now... keep this as a place holder. - Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status) + release_status = [item["status"] for item in result["media"]["releases"] if "download_info" in item and item["download_info"]["id"].lower() == download_id.lower()][0] + Logger.debug("This movie is marked as status %s, with release status %s, in CouchPotatoServer", movie_status, release_status) except: # index out of range/doesn't exist? Logger.exception("Could not find a status for this movie") movie_status = None From c5e38ef73daf312d5dc74f0b0eb79f3c835c369b Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 13:41:03 +1030 Subject: [PATCH 17/24] new api return --- autoProcess/autoProcessMovie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index be633ebb..914b41b1 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -75,7 +75,7 @@ def get_movie_info(baseURL, imdbid, download_id): try: result = json.load(urlObj) movieid2 = [item["_id"] for item in result["movies"]] - library2 = [item["identifier"] for item in result["movies"]] + library2 = [item["identifier"] for item in result["movies"] if "identifier" in item else item["identifiers"]["imdb"]] release2 = [item["releases"] for item in result["movies"]] moviestatus2 = [item["status"] for item in result["movies"]] except: From 4cfebd0c0507910c66b3f36359a0ca3515c70747 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 14:00:43 +1030 Subject: [PATCH 18/24] fix library id extraction --- autoProcess/autoProcessMovie.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 914b41b1..c9b2af72 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -75,7 +75,11 @@ def get_movie_info(baseURL, imdbid, download_id): try: result = json.load(urlObj) movieid2 = [item["_id"] for item in result["movies"]] - library2 = [item["identifier"] for item in result["movies"] if "identifier" in item else item["identifiers"]["imdb"]] + for item in result["movies"]: + if "identifier" in item: + library2.append(item["identifier"]) + else: + library2.append(item["identifiers"]["imdb"]) release2 = [item["releases"] for item in result["movies"]] moviestatus2 = [item["status"] for item in result["movies"]] except: From 3a4fe5223a785de78a779a0c0b8983c23bada8dc Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 16:39:08 +1030 Subject: [PATCH 19/24] more release status changes --- autoProcess/autoProcessMovie.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index c9b2af72..db11e7a8 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -130,9 +130,11 @@ def get_movie_info(baseURL, imdbid, download_id): return movie_id, imdbid, download_id, movie_status, release_status def get_status(baseURL, movie_id, download_id): - + + movie_status = None + release_status = None if not movie_id: - return None, None + return movie_status, release_status Logger.debug("Looking for status of movie: %s", movie_id) url = baseURL + "media.get/?id=" + str(movie_id) @@ -146,12 +148,19 @@ def get_status(baseURL, movie_id, download_id): try: result = json.load(urlObj) movie_status = str(result["media"]["status"]) - release_status = [item["status"] for item in result["media"]["releases"] if "download_info" in item and item["download_info"]["id"].lower() == download_id.lower()][0] - Logger.debug("This movie is marked as status %s, with release status %s, in CouchPotatoServer", movie_status, release_status) - except: # index out of range/doesn't exist? + Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status) + except: Logger.exception("Could not find a status for this movie") - movie_status = None - release_status = None + try: + if len(result["media"]["releases"]) == 1 and result["media"]["releases"][0]["status"] == "done": + release_status = result["media"]["releases"][0]["status"] + else: + release_status_list = [item["status"] for item in result["media"]["releases"] if "download_info" in item and item["download_info"]["id"].lower() == download_id.lower()] + if len(release_status_list) == 1: + release_status = release_status_list[0] + Logger.debug("This release is marked as status %s in CouchPotatoServer", release_status) + except: # index out of range/doesn't exist? + Logger.exception("Could not find a status for this release") return movie_status, release_status From 6580480382a7b4bd0ffda293921c8c724a72853d Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Mar 2014 16:54:20 +1030 Subject: [PATCH 20/24] fix when fork not = auto. --- autoProcess/autoSickBeardFork.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/autoProcess/autoSickBeardFork.py b/autoProcess/autoSickBeardFork.py index bbaaf405..e87625a0 100644 --- a/autoProcess/autoSickBeardFork.py +++ b/autoProcess/autoSickBeardFork.py @@ -50,20 +50,17 @@ def autoFork(fork=None): try: fork = config.get(section, "fork") - if not fork in "auto": - fork = fork if fork in SICKBEARD_FAILED or fork in SICKBEARD_TORRENT else fork_default - fork = [f for f in forks.iteritems() if f[0] == fork][0] except ConfigParser.NoOptionError: - fork = [f for f in forks.iteritems() if f[0] == fork_default][0] - - myOpener = AuthURLOpener(username, password) - - if ssl: - protocol = "https://" - else: - protocol = "http://" + fork = "auto" if fork in "auto": + myOpener = AuthURLOpener(username, password) + + if ssl: + protocol = "https://" + else: + protocol = "http://" + Logger.info("Attempting to auto-detect SickBeard fork") for f in forks.iteritems(): url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1]) @@ -78,5 +75,12 @@ def autoFork(fork=None): # failed to auto-detect fork Logger.info("SickBeard fork auto-detection failed") + else: #if not fork in "auto" + try: + fork = fork if fork in SICKBEARD_FAILED or fork in SICKBEARD_TORRENT else fork_default + fork = [f for f in forks.iteritems() if f[0] == fork][0] + except: + fork = [f for f in forks.iteritems() if f[0] == fork_default][0] + Logger.info("SickBeard fork set to %s", fork[0]) return fork[0], fork[1] \ No newline at end of file From a1e5dfa554d3bd0244a69100ca9c30f27bca37c7 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sun, 23 Mar 2014 01:32:14 +0100 Subject: [PATCH 21/24] Default SickBeard doesn't have a parameter "process" --- autoProcess/nzbToMediaEnv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index c078e000..bf49a822 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -14,7 +14,7 @@ fork_failed = "failed" fork_failed_torrent = "failed-torrent" forks = {} -forks[fork_default] = {"dir": None, "process": None} +forks[fork_default] = {"dir": None} forks[fork_failed] = {"dir": None, "failed": None} forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None} From 01c1328707540948388e93fb4777066904e3bf38 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 25 Mar 2014 09:57:37 +1030 Subject: [PATCH 22/24] reorder forks to check most-unique first. fixes #294 --- autoProcess/autoProcessTV.py | 6 ++++++ autoProcess/nzbToMediaEnv.py | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index b7a2d4db..89d0e8df 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -164,6 +164,12 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC if param is "dir": params["dir"] = dirName + if param is "process": + params["process"] = None + + if param is "process_method": + params["process_method"] = None + if nzbName != None: params['nzbName'] = nzbName diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index bf49a822..014a29c4 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -10,14 +10,18 @@ SABNZB_0717_NO_OF_ARGUMENTS = 9 # Constants pertaining to SickBeard Branches: fork_default = "default" +fork_default_new = "default-new" fork_failed = "failed" +fork_failed_new = "failed-new" fork_failed_torrent = "failed-torrent" forks = {} -forks[fork_default] = {"dir": None} -forks[fork_failed] = {"dir": None, "failed": None} forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None} +forks[fork_failed] = {"dirName": None, "failed": None} +forks[fork_failed_new] = {"dir": None, "failed": None} +forks[fork_default_new] = {"dir": None, "process": None} +forks[fork_default] = {"dir": None} -SICKBEARD_FAILED = [fork_failed, fork_failed_torrent] +SICKBEARD_FAILED = [fork_failed, fork_failed_torrent, fork_failed_new] SICKBEARD_TORRENT = [fork_failed_torrent] From 8242700032453858dd8f9710d93a4225ab5e9991 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 25 Mar 2014 13:47:07 +1030 Subject: [PATCH 23/24] ensure forks are ordered and parsed correctly. fixes #294 --- autoProcess/autoSickBeardFork.py | 14 +++++++------- autoProcess/nzbToMediaEnv.py | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/autoProcess/autoSickBeardFork.py b/autoProcess/autoSickBeardFork.py index e87625a0..8859814f 100644 --- a/autoProcess/autoSickBeardFork.py +++ b/autoProcess/autoSickBeardFork.py @@ -63,14 +63,14 @@ def autoFork(fork=None): Logger.info("Attempting to auto-detect SickBeard fork") for f in forks.iteritems(): - url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1]) + url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1]['params']) # attempting to auto-detect fork urlObj = myOpener.openit(url) if urlObj.getcode() == 200: - Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[0]) - return f[0], f[1] + Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[1]['name']) + return f[1]['name'], f[1]['params'] # failed to auto-detect fork Logger.info("SickBeard fork auto-detection failed") @@ -78,9 +78,9 @@ def autoFork(fork=None): else: #if not fork in "auto" try: fork = fork if fork in SICKBEARD_FAILED or fork in SICKBEARD_TORRENT else fork_default - fork = [f for f in forks.iteritems() if f[0] == fork][0] + fork = [f for f in forks.iteritems() if f[1]['name'] == fork][0] except: - fork = [f for f in forks.iteritems() if f[0] == fork_default][0] + fork = [f for f in forks.iteritems() if f[1]['name'] == fork_default][0] - Logger.info("SickBeard fork set to %s", fork[0]) - return fork[0], fork[1] \ No newline at end of file + Logger.info("SickBeard fork set to %s", fork[1]['name']) + return fork[1]['name'], fork[1]['params'] \ No newline at end of file diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index 014a29c4..fcfa240d 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -15,12 +15,12 @@ fork_failed = "failed" fork_failed_new = "failed-new" fork_failed_torrent = "failed-torrent" -forks = {} -forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None} -forks[fork_failed] = {"dirName": None, "failed": None} -forks[fork_failed_new] = {"dir": None, "failed": None} -forks[fork_default_new] = {"dir": None, "process": None} -forks[fork_default] = {"dir": None} +forks = {} # these need to be in order of most unique params first. +forks[1] = {'name': fork_failed_torrent, 'params': {"dir": None, "failed": None, "process_method": None}} +forks[2] = {'name': fork_failed, 'params': {"dirName": None, "failed": None}} +forks[3] = {'name': fork_failed_new, 'params': {"dir": None, "failed": None}} +forks[4] = {'name': fork_default_new, 'params': {"dir": None, "process": None}} +forks[5] = {'name': fork_default, 'params': {"dir": None}} SICKBEARD_FAILED = [fork_failed, fork_failed_torrent, fork_failed_new] SICKBEARD_TORRENT = [fork_failed_torrent] From bb3febaa9ccb6f4c4358ac617025f336fba7f64c Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 25 Mar 2014 14:04:45 +1030 Subject: [PATCH 24/24] simplify tests for extracted files. fixes #294 --- autoProcess/autoProcessTV.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index 89d0e8df..91634b97 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -125,12 +125,11 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC # auto-detect fork type fork, params = autoFork() - if (not fork in SICKBEARD_TORRENT) or (clientAgent in ['nzbget','sabnzbd'] and not nzbExtractionBy == "Destination"): + if nzbName != "Manual Run" and (not fork in SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and not nzbExtractionBy == "Destination")): process_all_exceptions(nzbName.lower(), dirName) nzbName, dirName = converto_to_ascii(nzbName, dirName) - if nzbName != "Manual Run" and not fork in SICKBEARD_TORRENT: - # Now check if movie files exist in destination: + # Now check if movie files exist in destination. Eventually extraction may be done here if nzbExtractionBy == TorrentToMedia video = int(0) for dirpath, dirnames, filenames in os.walk(dirName): for file in filenames: