mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -07:00
remove obsolete code and add transmissionrpc calls fixes #178
This commit is contained in:
parent
10406cffbe
commit
a6bc91ad0e
9 changed files with 40 additions and 79 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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...")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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...")
|
||||
|
|
|
@ -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...")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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...")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue