diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 373890a8..8e3c9b52 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -118,6 +118,11 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): time.sleep(5) # Give Torrent client some time to catch up with the change Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory) + + if inputCategory in hpCategory: + noFlatten.extend(hpCategory) # Make sure we preserve folder structure for HeadPhones. + if useLink in ['sym','move']: # These don't work for HeadPhones. + useLink = 'no' # default to copy. outputDestinationMaster = outputDestination # Save the original, so we can cahnge this within the lopp below, and reset afterwards. now = datetime.datetime.now() @@ -214,7 +219,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): continue outputDestination = outputDestinationMaster # Reset here. - if not inputCategory in hpCategory and not inputCategory in noFlatten: #don't flatten hp in case multi cd albums, and we need to copy this back later. + if not inputCategory in noFlatten: #don't flatten hp in case multi cd albums, and we need to copy this back later. flatten(outputDestination) # Now check if movie files exist in destination: @@ -281,7 +286,11 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): continue else: # move temp version back to allow seeding or Torrent removal. Logger.debug("MAIN: Moving %s to %s", str(item[1]), str(item[0])) - shutil.move(os.path.normpath(item[1]), os.path.normpath(item[0])) + newDestination = os.path.split(os.path.normpath(item[0])) + try: + copy_link(os.path.normpath(item[1]), os.path.normpath(item[0]), 'move', newDestination[0]) + except: + Logger.exception("MAIN: Failed to move file: %s", file) continue # Hardlink solution for uTorrent, need to implent support for deluge, transmission @@ -421,7 +430,7 @@ if __name__ == "__main__": Logger.info("MAIN: Loading config from %s", configFilename) config.read(configFilename) # EXAMPLE VALUES: - clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | other + clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other useLink = config.get("Torrent", "useLink") # no | hard | sym outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/ categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software diff --git a/autoProcess/nzbToMediaUtil.py b/autoProcess/nzbToMediaUtil.py index 177701a5..ac880ebe 100644 --- a/autoProcess/nzbToMediaUtil.py +++ b/autoProcess/nzbToMediaUtil.py @@ -363,8 +363,30 @@ def converto_to_ascii(nzbName, dirName): return nzbName, dirName def parse_other(args): - return os.path.normpath(sys.argv[1]), '', '', '', '' + return os.path.normpath(args[1]), '', '', '', '' +def parse_rtorrent(args): + # rtorrent usage: system.method.set_key = event.download.finished,TorrentToMedia, + # "execute={/path/to/nzbToMedia/TorrentToMedia.py,\"$d.get_base_path=\",\"$d.get_name=\",\"$d.get_custom1=\",\"$d.get_hash=\"}" + inputDirectory = os.path.normpath(args[1]) + try: + inputName = args[2] + except: + inputName = '' + try: + inputCategory = args[3] + except: + inputCategory = '' + try: + inputHash = args[4] + except: + inputHash = '' + try: + inputID = args[4] + except: + inputID = '' + + return inputDirectory, inputName, inputCategory, inputHash, inputID def parse_utorrent(args): # uTorrent usage: call TorrentToMedia.py "%D" "%N" "%L" "%I" @@ -408,6 +430,7 @@ def parse_transmission(args): __ARG_PARSERS__ = { 'other': parse_other, + 'rtorrent': parse_rtorrent, 'utorrent': parse_utorrent, 'deluge': parse_deluge, 'transmission': parse_transmission, diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index f46357b3..ccfe178e 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -77,7 +77,7 @@ web_root = [Torrent] -###### clientAgent - Supported clients: utorrent, transmission, deluge, other +###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, other clientAgent = other ###### useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy) useLink = hard diff --git a/changelog.txt b/changelog.txt index 5a05c801..42a9896c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -14,8 +14,10 @@ Make sure SickBeard receives the individula download dir. Disabled SickBeard Torrent handling for NZBs. Fixes failed handling of nzbs that fail to extract. Impacts Torrents -Added option to run userscript once only (on directory) +Added option to run userscript once only (on directory). Added Option to not flatten specific categories. +Added rtorrent integration. +Fixes for HeadPhones use (no flatten), no move/sym, and fix move back to original. V9.1 24/01/2014