diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 94d15b39..82bde3d3 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -23,6 +23,7 @@ import autoProcess.autoProcessMovie as autoProcessMovie from autoProcess.nzbToMediaEnv import * from autoProcess.nzbToMediaUtil import * from utorrent.client import UTorrentClient +from transmissionrpc.client import Client as TransmissionClient def main(inputDirectory, inputName, inputCategory, inputHash, inputID): @@ -138,24 +139,37 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): status = 0 # Hardlink solution for uTorrent, need to implent support for deluge, transmission - if clientAgent == 'utorrent' and extractionSuccess == False and inputHash: - try: - Logger.debug("MAIN: Connecting to uTorrent: %s", uTorrentWEBui) - utorrentClass = UTorrentClient(uTorrentWEBui, uTorrentUSR, uTorrentPWD) - except: - Logger.exception("MAIN: Failed to connect to uTorrent") + if clientAgent in ['utorrent', 'transmission'] and extractionSuccess == False and inputHash: + if clientAgent == 'utorrent': + try: + Logger.debug("MAIN: Connecting to %s: %s", clientAgent, uTorrentWEBui) + utorrentClass = UTorrentClient(uTorrentWEBui, uTorrentUSR, uTorrentPWD) + except: + Logger.exception("MAIN: Failed to connect to uTorrent") + else: + try: + Logger.debug("MAIN: Connecting to %s: http://%s:%s", clientAgent, TransmissionHost, TransmissionPort) + TransmissionClass = TransmissionClient(TransmissionHost, TransmissionPort, TransmissionUSR, TransmissionPWD) + except: + Logger.exception("MAIN: Failed to connect to Transmission") # if we are using links with uTorrent it means we need to pause it in order to access the files if useLink != "no": - Logger.debug("MAIN: Stoping torrent %s in uTorrent while processing", inputName) - utorrentClass.stop(inputHash) + Logger.debug("MAIN: Stoping torrent %s in %s while processing", inputName, clientAgent) + if clientAgent == 'utorrent': + utorrentClass.stop(inputHash) + else: + TransmissionClass.stop_torrent(inputID) time.sleep(5) # Give uTorrent some time to catch up with the change # Delete torrent and torrentdata from uTorrent if deleteOriginal == 1: - Logger.debug("MAIN: Deleting torrent %s from uTorrent", inputName) - utorrentClass.removedata(inputHash) - utorrentClass.remove(inputHash) + Logger.debug("MAIN: Deleting torrent %s from %s", inputName, clientAgent) + if clientAgent == 'utorrent': + utorrentClass.removedata(inputHash) + utorrentClass.remove(inputHash) + else: + TransmissionClass.remove_torrent(inputID, True) time.sleep(5) processCategories = Set([cpsCategory, sbCategory, hpCategory, mlCategory, gzCategory]) @@ -196,8 +210,11 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): # Hardlink solution for uTorrent, need to implent support for deluge, transmission if clientAgent == 'utorrent' and extractionSuccess == False and inputHash and useLink != "no" and deleteOriginal == 0: # we always want to resume seeding, for now manually find out what is wrong when extraction fails - Logger.debug("MAIN: Starting torrent %s in uTorrent", inputName) - utorrentClass.start(inputHash) + Logger.debug("MAIN: Starting torrent %s in %s", inputName, clientAgent) + if clientAgent == 'utorrent': + utorrentClass.start(inputHash) + else: + TransmissionClass.start_torrent(inputID) Logger.info("MAIN: All done.") @@ -235,6 +252,11 @@ if __name__ == "__main__": uTorrentWEBui = config.get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/ uTorrentUSR = config.get("Torrent", "uTorrentUSR") # mysecretusr uTorrentPWD = config.get("Torrent", "uTorrentPWD") # mysecretpwr + + TransmissionWEBui = config.get("Torrent", "TransmissionHost") # localhost + TransmissionWEBui = config.get("Torrent", "TransmissionPort") # 8084 + TransmissionUSR = config.get("Torrent", "TransmissionUSR") # mysecretusr + TransmissionPWD = config.get("Torrent", "TransmissionPWD") # mysecretpwr deleteOriginal = int(config.get("Torrent", "deleteOriginal")) # 0 diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index bd012f5a..5d7a701a 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -6,5 +6,3 @@ VERSION = 'V8.4' # Constants pertinant to SabNzb SABNZB_NO_OF_ARGUMENTS = 8 -# Constants pertinant to NzbGet -NZBGET_NO_OF_ARGUMENTS = 6 diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index c15c7a4a..7a170fa7 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -88,6 +88,11 @@ categories = music_videos,pictures,software uTorrentWEBui = http://localhost:8090/gui/ uTorrentUSR = your username uTorrentPWD = your password +###### Transmission (You must edit this if your using TorrentToMedia.py with uTorrent) +TransmissionHost = localhost +TransmissionPort = 8084 +TransmissionUSR = your username +TransmissionPWD = your password ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ###### deleteOriginal = 0 diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index c92d1812..ea95f6a1 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -218,17 +218,6 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: Logger.info("Script triggered from SABnzbd, starting autoProcessMovie...") clientAgent = "sabnzbd" result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent) -# NZBGet V10 or earlier -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("Script triggered from NZBGet, starting autoProcessMovie...") - clientAgent = "nzbget" - result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[3], clientAgent, sys.argv[5]) else: Logger.warn("Invalid number of arguments received from client.") Logger.info("Running autoProcessMovie as a manual run...") diff --git a/nzbToGamez.py b/nzbToGamez.py index a41ef748..873a90a9 100755 --- a/nzbToGamez.py +++ b/nzbToGamez.py @@ -158,16 +158,6 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 Logger.info("Script triggered from SABnzbd, starting autoProcessGames...") result = autoProcessGames.process(sys.argv[1], sys.argv[3], sys.argv[7]) -# NZBGet -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("Script triggered from NZBGet, starting autoProcessGames...") - result = autoProcessGames.process(sys.argv[1], sys.argv[2], sys.argv[3]) else: Logger.warn("Invalid number of arguments received from client. Exiting") sys.exit(1) diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index e7daec1b..dfc4cc66 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -163,16 +163,6 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 Logger.info("Script triggered from SABnzbd, starting autoProcessMusic...") result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[7]) -# NZBGet -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("Script triggered from NZBGet, starting autoProcessMusic...") - result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[3]) else: Logger.warn("Invalid number of arguments received from client.") Logger.info("Running autoProcessMusic as a manual run...") diff --git a/nzbToMedia.py b/nzbToMedia.py index 2dd0572e..650f082f 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -366,18 +366,6 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: Logger.info("MAIN: Script triggered from SABnzbd") clientAgent = "sabnzbd" nzbDir, inputName, status, inputCategory, download_id = (sys.argv[1], sys.argv[2], sys.argv[7], sys.argv[5], '') -# NZBGet -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # nzbget v10 or earlier. - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("MAIN: Script triggered from NZBGet") - clientAgent = "nzbget" - nzbDir, inputName, status, inputCategory, download_id = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) - else: # only CPS supports this manual run for now. Logger.warn("MAIN: Invalid number of arguments received from client.") Logger.info("MAIN: Running autoProcessMovie as a manual run...") diff --git a/nzbToMylar.py b/nzbToMylar.py index fc88ffb2..e9dfad25 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -161,18 +161,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 Logger.info("Script triggered from SABnzbd, starting autoProcessComics...") result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[3], sys.argv[7]) -# NZBGet -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("Script triggered from NZBGet, starting autoProcessComics...") - result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3]) else: - Logger.warn("Invalid number of arguments received from client.") Logger.info("Running autoProcessComics as a manual run...") result = autoProcessComics.processEpisode('Manual Run', 'Manual Run', 0) diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 0ded9d61..4fd9752d 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -210,16 +210,6 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 Logger.info("Script triggered from SABnzbd, starting autoProcessTV...") result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7]) -# NZBGet -elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: - # NZBGet argv: - # 1 The final directory of the job (full path) - # 2 The original name of the NZB file - # 3 The status of the download: 0 == successful - # 4 The category of the download: - # 5 The download_id - Logger.info("Script triggered from NZBGet, starting autoProcessTV...") - result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3]) else: Logger.debug("Invalid number of arguments received from client.") Logger.info("Running autoProcessTV as a manual run...")