diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 19dda177..3d4f019d 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -286,7 +286,6 @@ def external_script(outputDestination, torrentName, torrentLabel): result = int(1) final_result = final_result + result - time.sleep(nzbtomedia.USER_DELAY) num_files_new = 0 for dirpath, dirnames, filenames in os.walk(outputDestination): for file in filenames: @@ -363,7 +362,7 @@ def main(args): except: inputID = None - if clientAgent.lower() not in (nzbtomedia.TORRENT_CLIENTS or ['manual']): + if clientAgent.lower() not in nzbtomedia.TORRENT_CLIENTS and clientAgent != 'manual': continue results = processTorrent(dirName, os.path.basename(dirName), subsection, inputHash, inputID, diff --git a/nzbToMedia.py b/nzbToMedia.py index 65ff124b..01c941c9 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -485,7 +485,7 @@ def main(args, section=None): except: download_id = None - if clientAgent.lower() not in (nzbtomedia.NZB_CLIENTS or ['manual']): + if clientAgent.lower() not in nzbtomedia.NZB_CLIENTS and clientAgent != 'manual': continue results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index f1fd8294..89d041c2 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -139,46 +139,48 @@ def is_sample(inputName): return True def copy_link(src, targetLink, useLink): - if os.path.exists(targetLink): - logger.info("%s already exists. skipping ..." % (os.path.basename(targetLink)), 'COPYLINK') + logger.info("MEDIAFILE: [%s]" % (os.path.basename(targetLink)), 'COPYLINK') + logger.info("SOURCE FOLDER: [%s]" % (os.path.dirname(src)), 'COPYLINK') + logger.info("TARGET FOLDER: [%s]" % (os.path.dirname(targetLink)), 'COPYLINK') + + if src != targetLink and os.path.exists(targetLink): + logger.info("MEDIAFILE already exists in the TARGET folder, skipping ...", 'COPYLINK') + return True + elif src == targetLink: + logger.info("SOURCE AND TARGET folders are the same, skipping ...", 'COPYLINK') return True makeDir(os.path.dirname(targetLink)) - try: if useLink == 'dir': - logger.info("Directory linking %s to %s" % (src, targetLink), 'COPYLINK') + logger.info("Directory linking SOURCE FOLDER -> TARGET FOLDER", 'COPYLINK') linktastic.dirlink(src, targetLink) return True if useLink == 'junction': - logger.info("Directory junction linking %s to %s" % (src, targetLink), 'COPYLINK') + logger.info("Directory junction linking SOURCE FOLDER -> TARGET FOLDER", 'COPYLINK') linktastic.dirlink(src, targetLink) return True elif useLink == "hard": - logger.info("Hard linking %s to %s" % (src, targetLink), 'COPYLINK') + logger.info("Hard linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK') linktastic.link(src, targetLink) return True elif useLink == "sym": - logger.info("Moving %s to %s before sym linking" % (src, targetLink), 'COPYLINK') + logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK') shutil.move(src, targetLink) - logger.info("Sym linking %s to %s" % (targetLink, src), 'COPYLINK') linktastic.symlink(targetLink, src) return True elif useLink == "move": - logger.debug("Moving %s to %s" % (src, targetLink)) + logger.info("Moving SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK') shutil.move(src, targetLink) return True except Exception, e: logger.warning("Error: %s, copying instead ... " % (e), 'COPYLINK') - logger.debug("Copying %s to %s" % (src, targetLink), 'COPYLINK') - shutil.copy(src, targetLink) - logger.debug("Copying %s to %s" % (src, targetLink)) + logger.info("Copying SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK') shutil.copy(src, targetLink) return True - def flatten(outputDestination): logger.info("FLATTEN: Flattening directory: %s" % (outputDestination)) for outputFile in listMediaFiles(outputDestination): @@ -388,6 +390,9 @@ def getDirs(section, subsection): def processDir(path): folders = [] + + logger.info("Searching %s for mediafiles to post-process ..." % (path)) + # search for single files and move them into there own folder for post-processing for mediafile in listMediaFiles(path): parentDir = os.path.dirname(mediafile) @@ -437,7 +442,7 @@ def getDirs(section, subsection): return folders try: - watch_dir = nzbtomedia.CFG[section][subsection]["watch_dir"] + watch_dir = os.path.join(nzbtomedia.CFG[section][subsection]["watch_dir"], subsection) if os.path.exists(watch_dir): to_return.extend(processDir(watch_dir)) except:pass