From e3bb60aa57f4fb975c3e519db44a0823dfbc278d Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Thu, 3 Apr 2014 12:50:35 +1030 Subject: [PATCH] change handling of SB_Torrent. --- TorrentToMedia.py | 21 +++------------------ autoProcess/autoProcessTV.py | 8 +++++++- autoProcess/migratecfg.py | 2 ++ autoProcessMedia.cfg.sample | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 1507d29b..cdf976df 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -40,7 +40,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): sbFork, sbParams = autoFork() - if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT and Torrent_ForceLink != 1: + if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT and Torrent_NoLink == 1: Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",sbFork ,inputName) result = autoProcessTV.processEpisode(inputDirectory, inputName, int(0)) if result == 1: @@ -121,8 +121,6 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory) noFlatten.extend(hpCategory) # Make sure we preserve folder structure for HeadPhones. - if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT: # Don't flatten when sending to SICKBEARD_TORRENT - noFlatten.extend(sbCategory) outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards. now = datetime.datetime.now() @@ -163,15 +161,6 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): else: continue # This file has not been recently moved or created, skip it - if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT: # We want to link every file. - Logger.info("MAIN: Found file %s in %s", fileExtension, filePath) - try: - copy_link(filePath, targetDirectory, useLink, outputDestination) - copy_list.append([filePath, os.path.join(outputDestination, file)]) - except: - Logger.exception("MAIN: Failed to link file: %s", file) - continue - if fileExtension in mediaContainer: # If the file is a video file if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in hpCategory: # Ignore samples Logger.info("MAIN: Ignoring sample file: %s ", filePath) @@ -223,7 +212,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): flatten(outputDestination) # Now check if movie files exist in destination: - if inputCategory in cpsCategory + sbCategory and not (inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT): + if inputCategory in cpsCategory + sbCategory: for dirpath, dirnames, filenames in os.walk(outputDestination): for file in filenames: filePath = os.path.join(dirpath, file) @@ -243,10 +232,6 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): else: Logger.debug("MAIN: Found %s media files in output. %s were found in input", str(video2), str(video)) - if inputCategory in sbCategory and sbFork in SICKBEARD_TORRENT: - if len(copy_list) > 0: - Logger.debug("MAIN: Found and linked %s files", str(len(copy_list))) - status = int(0) processCategories = cpsCategory + sbCategory + hpCategory + mlCategory + gzCategory @@ -449,7 +434,7 @@ if __name__ == "__main__": cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv - Torrent_ForceLink = int(config().get("SickBeard", "Torrent_ForceLink")) # 1 + Torrent_NoLink = int(config().get("SickBeard", "Torrent_NoLink")) # 0 hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') # music mlCategory = (config().get("Mylar", "mlCategory")).split(',') # comics gzCategory = (config().get("Gamez", "gzCategory")).split(',') # games diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index 2cb3a3c7..70163467 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -98,6 +98,10 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent = "manual", process_method = config().get(section, "process_method") except config.NoOptionError: process_method = None + try: + Torrent_NoLink = int(config().get(section, "Torrent_NoLink")) + except (config.NoOptionError, ValueError): + Torrent_NoLink = 0 mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',') minSampleSize = int(config().get("Extensions", "minSampleSize")) @@ -160,7 +164,9 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent = "manual", params[param] = dirName if param == "process_method": - if process_method: + if fork in SICKBEARD_TORRENT and Torrent_NoLink == 1 and not clientAgent in ['nzbget','sabnzbd']: #use default SickBeard settings here. + del params[param] + elif process_method: params[param] = process_method else: del params[param] diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index 9dc8c7c8..9d9d9841 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -31,6 +31,8 @@ def migrate(): value = "auto" if option == "fork" and value not in ["default", "failed", "failed-torrent", "auto"]: value = "auto" + if option == "Torrent_ForceLink": + continue 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/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 97731862..ca174642 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -37,7 +37,7 @@ watch_dir = fork = auto delete_failed = 0 nzbExtractionBy = Downloader -Torrent_ForceLink = 1 +Torrent_NoLink = 0 process_method =