added rtorrent #263 and fixes for HeadPhones #257

This commit is contained in:
clinton-hall 2014-02-14 10:19:04 +10:30
commit 52d3b016f0
4 changed files with 40 additions and 6 deletions

View file

@ -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 time.sleep(5) # Give Torrent client some time to catch up with the change
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory) 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. outputDestinationMaster = outputDestination # Save the original, so we can cahnge this within the lopp below, and reset afterwards.
now = datetime.datetime.now() now = datetime.datetime.now()
@ -214,7 +219,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
continue continue
outputDestination = outputDestinationMaster # Reset here. 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) flatten(outputDestination)
# Now check if movie files exist in destination: # Now check if movie files exist in destination:
@ -281,7 +286,11 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
continue continue
else: # move temp version back to allow seeding or Torrent removal. else: # move temp version back to allow seeding or Torrent removal.
Logger.debug("MAIN: Moving %s to %s", str(item[1]), str(item[0])) 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 continue
# Hardlink solution for uTorrent, need to implent support for deluge, transmission # 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) Logger.info("MAIN: Loading config from %s", configFilename)
config.read(configFilename) config.read(configFilename)
# EXAMPLE VALUES: # 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 useLink = config.get("Torrent", "useLink") # no | hard | sym
outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/ outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/
categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software

View file

@ -363,8 +363,30 @@ def converto_to_ascii(nzbName, dirName):
return nzbName, dirName return nzbName, dirName
def parse_other(args): 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): def parse_utorrent(args):
# uTorrent usage: call TorrentToMedia.py "%D" "%N" "%L" "%I" # uTorrent usage: call TorrentToMedia.py "%D" "%N" "%L" "%I"
@ -408,6 +430,7 @@ def parse_transmission(args):
__ARG_PARSERS__ = { __ARG_PARSERS__ = {
'other': parse_other, 'other': parse_other,
'rtorrent': parse_rtorrent,
'utorrent': parse_utorrent, 'utorrent': parse_utorrent,
'deluge': parse_deluge, 'deluge': parse_deluge,
'transmission': parse_transmission, 'transmission': parse_transmission,

View file

@ -77,7 +77,7 @@ web_root =
[Torrent] [Torrent]
###### clientAgent - Supported clients: utorrent, transmission, deluge, other ###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, other
clientAgent = 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 - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy)
useLink = hard useLink = hard

View file

@ -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. Disabled SickBeard Torrent handling for NZBs. Fixes failed handling of nzbs that fail to extract.
Impacts Torrents 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 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 V9.1 24/01/2014