mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
All processing sections now can enable/disable linking for torrents via TorrentNoLink option in autoProcessMedia.cfg
Cleanup/removal of processed files on start and finish of our nzbToMedia and TorrentToMedia scripts to insure things stay nice and polished :) Code tweaked and cleaned and fed a energy drink so stay on the look out this things alive ! lol
This commit is contained in:
parent
0053fdcf3e
commit
27d722e8b1
5 changed files with 69 additions and 64 deletions
|
@ -14,7 +14,7 @@ from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
||||||
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
|
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
|
||||||
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
|
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
|
||||||
from nzbtomedia.nzbToMediaUtil import category_search, sanitizeFileName, copy_link, parse_args, flatten, get_dirnames, \
|
from nzbtomedia.nzbToMediaUtil import category_search, sanitizeFileName, copy_link, parse_args, flatten, get_dirnames, \
|
||||||
remove_read_only, create_torrent_class, pause_torrent, resume_torrent, listMediaFiles, joinPath, \
|
remove_read_only, pause_torrent, resume_torrent, listMediaFiles, joinPath, \
|
||||||
extractFiles, cleanProcDirs
|
extractFiles, cleanProcDirs
|
||||||
from nzbtomedia import logger
|
from nzbtomedia import logger
|
||||||
|
|
||||||
|
@ -41,10 +41,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
"We could not find a section with containing a download category labeled %s in your autoProcessMedia.cfg, Exiting!" % inputCategory)
|
"We could not find a section with containing a download category labeled %s in your autoProcessMedia.cfg, Exiting!" % inputCategory)
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
TorrentClass = None
|
Torrent_NoLink = int(nzbtomedia.CFG[section][inputCategory]["Torrent_NoLink"])
|
||||||
|
|
||||||
if clientAgent != 'manual':
|
if clientAgent != 'manual':
|
||||||
TorrentClass = create_torrent_class(clientAgent)
|
pause_torrent(clientAgent, inputHash, inputID, inputName)
|
||||||
pause_torrent(clientAgent, TorrentClass, inputHash, inputID, inputName)
|
|
||||||
|
|
||||||
processCategories = nzbtomedia.CFG[nzbtomedia.SECTIONS].sections
|
processCategories = nzbtomedia.CFG[nzbtomedia.SECTIONS].sections
|
||||||
|
|
||||||
|
@ -53,19 +53,6 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
outputDestination = os.path.normpath(joinPath(nzbtomedia.OUTPUTDIRECTORY, inputCategory, sanitizeFileName(inputName)))
|
outputDestination = os.path.normpath(joinPath(nzbtomedia.OUTPUTDIRECTORY, inputCategory, sanitizeFileName(inputName)))
|
||||||
logger.info("Output directory set to: %s" % (outputDestination))
|
logger.info("Output directory set to: %s" % (outputDestination))
|
||||||
|
|
||||||
if nzbtomedia.CFG["SickBeard"][inputCategory]:
|
|
||||||
Torrent_NoLink = int(nzbtomedia.CFG["SickBeard"][inputCategory]["Torrent_NoLink"]) # 0
|
|
||||||
if Torrent_NoLink == 1:
|
|
||||||
logger.info("Calling autoProcessTV to post-process: %s",inputName)
|
|
||||||
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0, clientAgent=clientAgent, inputCategory=inputCategory)
|
|
||||||
if result != 0:
|
|
||||||
logger.error("A problem was reported in the autoProcessTV script.")
|
|
||||||
|
|
||||||
if clientAgent != 'manual':
|
|
||||||
resume_torrent(clientAgent, TorrentClass, inputHash, inputID, result, inputName)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
processOnly = nzbtomedia.CFG[nzbtomedia.SECTIONS].sections
|
processOnly = nzbtomedia.CFG[nzbtomedia.SECTIONS].sections
|
||||||
if not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES: # if None, we only process the 5 listed.
|
if not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES: # if None, we only process the 5 listed.
|
||||||
if "ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES: # All defined categories
|
if "ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES: # All defined categories
|
||||||
|
@ -120,13 +107,15 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
else:
|
else:
|
||||||
continue # This file has not been recently moved or created, skip it
|
continue # This file has not been recently moved or created, skip it
|
||||||
|
|
||||||
try:
|
if Torrent_NoLink == 0:
|
||||||
copy_link(inputFile, targetDirectory, nzbtomedia.USELINK, outputDestination)
|
try:
|
||||||
copy_list.append([inputFile, joinPath(outputDestination, fullFileName)])
|
copy_link(inputFile, targetDirectory, nzbtomedia.USELINK, outputDestination)
|
||||||
except:
|
copy_list.append([inputFile, joinPath(outputDestination, fullFileName)])
|
||||||
logger.error("Failed to link file: %s" % (fullFileName))
|
except:
|
||||||
|
logger.error("Failed to link file: %s" % (fullFileName))
|
||||||
|
|
||||||
outputDestination = outputDestinationMaster # Reset here.
|
outputDestination = outputDestinationMaster # Reset here.
|
||||||
|
|
||||||
if not inputCategory in nzbtomedia.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later.
|
if not inputCategory in nzbtomedia.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later.
|
||||||
flatten(outputDestination)
|
flatten(outputDestination)
|
||||||
|
|
||||||
|
@ -187,7 +176,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
|
|
||||||
if result != 0 and clientAgent != 'manual':
|
if result != 0 and clientAgent != 'manual':
|
||||||
logger.error("A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding")
|
logger.error("A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding")
|
||||||
resume_torrent(clientAgent, TorrentClass, inputHash, inputID, result, inputName)
|
resume_torrent(clientAgent, inputHash, inputID, result, inputName)
|
||||||
|
else:
|
||||||
|
# cleanup our processing folders of any misc unwanted files and empty directories
|
||||||
|
cleanProcDirs()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -309,9 +301,6 @@ def main(args):
|
||||||
logger.warning("%s:%s is DISABLED, you can enable this in autoProcessMedia.cfg ..." % (section, category))
|
logger.warning("%s:%s is DISABLED, you can enable this in autoProcessMedia.cfg ..." % (section, category))
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
# cleanup our processing folders of any misc unwanted files and empty directories
|
|
||||||
cleanProcDirs()
|
|
||||||
|
|
||||||
logger.info("The %s script completed successfully." % (args[0]))
|
logger.info("The %s script completed successfully." % (args[0]))
|
||||||
else:
|
else:
|
||||||
logger.error("A problem was reported in the %s script." % (args[0]))
|
logger.error("A problem was reported in the %s script." % (args[0]))
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
method = renamer
|
method = renamer
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
wait_for = 2
|
wait_for = 2
|
||||||
|
@ -52,6 +54,7 @@
|
||||||
ssl = 0
|
ssl = 0
|
||||||
fork = auto
|
fork = auto
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
process_method =
|
process_method =
|
||||||
extract = 1
|
extract = 1
|
||||||
|
@ -74,6 +77,7 @@
|
||||||
web_root =
|
web_root =
|
||||||
ssl = 0
|
ssl = 0
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
|
@ -93,6 +97,8 @@
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
wait_for = 2
|
wait_for = 2
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
|
@ -111,6 +117,8 @@
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
web_root=
|
web_root=
|
||||||
ssl=0
|
ssl=0
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
|
@ -128,6 +136,8 @@
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
|
|
|
@ -311,6 +311,10 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
logger.error("We could not find a section with containing a download category labeled %s in your autoProcessMedia.cfg, Exiting!" % inputCategory)
|
logger.error("We could not find a section with containing a download category labeled %s in your autoProcessMedia.cfg, Exiting!" % inputCategory)
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
# cleanup our processing folders of any misc unwanted files and empty directories
|
||||||
|
cleanProcDirs()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def main(args, section=None):
|
def main(args, section=None):
|
||||||
|
@ -423,13 +427,13 @@ def main(args, section=None):
|
||||||
if results != 0:
|
if results != 0:
|
||||||
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (section, category))
|
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (section, category))
|
||||||
result = results
|
result = results
|
||||||
|
|
||||||
|
if len(dirNames) == 0:
|
||||||
|
logger.info('[%s] - No directories found to post-process ...' % (str(category).upper()), section)
|
||||||
else:
|
else:
|
||||||
logger.debug("nzbToMedia %s:%s is DISABLED" % (section, category))
|
logger.debug("nzbToMedia %s:%s is DISABLED" % (section, category))
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
# cleanup our processing folders of any misc unwanted files and empty directories
|
|
||||||
cleanProcDirs()
|
|
||||||
|
|
||||||
logger.info("The %s script completed successfully." % args[0])
|
logger.info("The %s script completed successfully." % args[0])
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
|
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
|
||||||
|
|
|
@ -21,7 +21,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(PROGRAM_DIR, 'lib')))
|
||||||
|
|
||||||
from nzbtomedia import logger, versionCheck
|
from nzbtomedia import logger, versionCheck
|
||||||
from nzbtomedia.nzbToMediaConfig import config
|
from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import WakeUp, makeDir, joinPath, cleanProcDirs
|
from nzbtomedia.nzbToMediaUtil import WakeUp, makeDir, joinPath, cleanProcDirs, create_torrent_class
|
||||||
|
|
||||||
# sabnzbd constants
|
# sabnzbd constants
|
||||||
SABNZB_NO_OF_ARGUMENTS = 8
|
SABNZB_NO_OF_ARGUMENTS = 8
|
||||||
|
@ -65,6 +65,7 @@ SABNZBDPORT = None
|
||||||
SABNZBDAPIKEY = None
|
SABNZBDAPIKEY = None
|
||||||
|
|
||||||
TORRENT_CLIENTAGENT = None
|
TORRENT_CLIENTAGENT = None
|
||||||
|
TORRENT_CLASS = None
|
||||||
USELINK = None
|
USELINK = None
|
||||||
OUTPUTDIRECTORY = None
|
OUTPUTDIRECTORY = None
|
||||||
CATEGORIES = []
|
CATEGORIES = []
|
||||||
|
@ -137,7 +138,7 @@ def initialize(section=None):
|
||||||
TRANSCODE, GIT_PATH, GIT_USER, GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \
|
TRANSCODE, GIT_PATH, GIT_USER, GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \
|
||||||
DUPLICATE, IGNOREEXTENSIONS, OUTPUTVIDEOEXTENSION, OUTPUTVIDEOCODEC, OUTPUTVIDEOPRESET, OUTPUTVIDEOFRAMERATE, \
|
DUPLICATE, IGNOREEXTENSIONS, OUTPUTVIDEOEXTENSION, OUTPUTVIDEOCODEC, OUTPUTVIDEOPRESET, OUTPUTVIDEOFRAMERATE, \
|
||||||
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
|
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
|
||||||
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER
|
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
|
@ -310,6 +311,9 @@ def initialize(section=None):
|
||||||
SUBSECTIONS = CFG[SECTIONS]
|
SUBSECTIONS = CFG[SECTIONS]
|
||||||
CATEGORIES += SUBSECTIONS.sections
|
CATEGORIES += SUBSECTIONS.sections
|
||||||
|
|
||||||
|
# create torrent class
|
||||||
|
TORRENT_CLASS = create_torrent_class(TORRENT_CLIENTAGENT)
|
||||||
|
|
||||||
# cleanup our processing folders of any misc unwanted files and empty directories
|
# cleanup our processing folders of any misc unwanted files and empty directories
|
||||||
cleanProcDirs()
|
cleanProcDirs()
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ def get_dirnames(section, subsections=None):
|
||||||
os.path.isdir(joinPath(outputDirectory, o))])
|
os.path.isdir(joinPath(outputDirectory, o))])
|
||||||
|
|
||||||
if not dirNames:
|
if not dirNames:
|
||||||
logger.warning("%s:%s has no directories identified for post-processing" % (section, subsection))
|
logger.debug("No directories identified in %s for post-processing" % (subsection), section)
|
||||||
|
|
||||||
return list(set(dirNames))
|
return list(set(dirNames))
|
||||||
|
|
||||||
|
@ -454,11 +454,12 @@ def cleanProcDirs():
|
||||||
|
|
||||||
def create_torrent_class(clientAgent):
|
def create_torrent_class(clientAgent):
|
||||||
# Hardlink solution for Torrents
|
# Hardlink solution for Torrents
|
||||||
TorrentClass = None
|
tc = None
|
||||||
|
|
||||||
if clientAgent == 'utorrent':
|
if clientAgent == 'utorrent':
|
||||||
try:
|
try:
|
||||||
logger.debug("Connecting to %s: %s" % (clientAgent, nzbtomedia.UTORRENTWEBUI))
|
logger.debug("Connecting to %s: %s" % (clientAgent, nzbtomedia.UTORRENTWEBUI))
|
||||||
TorrentClass = UTorrentClient(nzbtomedia.UTORRENTWEBUI, nzbtomedia.UTORRENTUSR, nzbtomedia.UTORRENTPWD)
|
tc = UTorrentClient(nzbtomedia.UTORRENTWEBUI, nzbtomedia.UTORRENTUSR, nzbtomedia.UTORRENTPWD)
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to connect to uTorrent")
|
logger.error("Failed to connect to uTorrent")
|
||||||
|
|
||||||
|
@ -466,7 +467,7 @@ def create_torrent_class(clientAgent):
|
||||||
try:
|
try:
|
||||||
logger.debug("Connecting to %s: http://%s:%s" % (
|
logger.debug("Connecting to %s: http://%s:%s" % (
|
||||||
clientAgent, nzbtomedia.TRANSMISSIONHOST, nzbtomedia.TRANSMISSIONPORT))
|
clientAgent, nzbtomedia.TRANSMISSIONHOST, nzbtomedia.TRANSMISSIONPORT))
|
||||||
TorrentClass = TransmissionClient(nzbtomedia.TRANSMISSIONHOST, nzbtomedia.TRANSMISSIONPORT,
|
tc = TransmissionClient(nzbtomedia.TRANSMISSIONHOST, nzbtomedia.TRANSMISSIONPORT,
|
||||||
nzbtomedia.TRANSMISSIONUSR,
|
nzbtomedia.TRANSMISSIONUSR,
|
||||||
nzbtomedia.TRANSMISSIONPWD)
|
nzbtomedia.TRANSMISSIONPWD)
|
||||||
except:
|
except:
|
||||||
|
@ -475,64 +476,61 @@ def create_torrent_class(clientAgent):
|
||||||
if clientAgent == 'deluge':
|
if clientAgent == 'deluge':
|
||||||
try:
|
try:
|
||||||
logger.debug("Connecting to %s: http://%s:%s" % (clientAgent, nzbtomedia.DELUGEHOST, nzbtomedia.DELUGEPORT))
|
logger.debug("Connecting to %s: http://%s:%s" % (clientAgent, nzbtomedia.DELUGEHOST, nzbtomedia.DELUGEPORT))
|
||||||
TorrentClass = DelugeClient()
|
tc = DelugeClient()
|
||||||
TorrentClass.connect(host=nzbtomedia.DELUGEHOST, port=nzbtomedia.DELUGEPORT, username=nzbtomedia.DELUGEUSR,
|
tc.connect(host=nzbtomedia.DELUGEHOST, port=nzbtomedia.DELUGEPORT, username=nzbtomedia.DELUGEUSR,
|
||||||
password=nzbtomedia.DELUGEPWD)
|
password=nzbtomedia.DELUGEPWD)
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to connect to Deluge")
|
logger.error("Failed to connect to Deluge")
|
||||||
|
|
||||||
return TorrentClass
|
return tc
|
||||||
|
|
||||||
|
|
||||||
def pause_torrent(clientAgent, TorrentClass, inputHash, inputID, inputName):
|
def pause_torrent(clientAgent, inputHash, inputID, inputName):
|
||||||
# if we are using links with Torrents it means we need to pause it in order to access the files
|
# if we are using links with Torrents it means we need to pause it in order to access the files
|
||||||
logger.debug("Stoping torrent %s in %s while processing" % (inputName, clientAgent))
|
logger.debug("Stoping torrent %s in %s while processing" % (inputName, clientAgent))
|
||||||
if clientAgent == 'utorrent' and TorrentClass != "":
|
if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.stop(inputHash)
|
nzbtomedia.TORRENT_CLASS.stop(inputHash)
|
||||||
if clientAgent == 'transmission' and TorrentClass != "":
|
if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.stop_torrent(inputID)
|
nzbtomedia.TORRENT_CLASS.stop_torrent(inputID)
|
||||||
if clientAgent == 'deluge' and TorrentClass != "":
|
if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.core.pause_torrent([inputID])
|
nzbtomedia.TORRENT_CLASS.core.pause_torrent([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
|
||||||
|
|
||||||
|
|
||||||
def resume_torrent(clientAgent, TorrentClass, inputHash, inputID, result, inputName):
|
def resume_torrent(clientAgent, inputHash, inputID, result, inputName):
|
||||||
# Hardlink solution for uTorrent, need to implent support for deluge, transmission
|
# Hardlink solution for uTorrent, need to implent support for deluge, transmission
|
||||||
if clientAgent in ['utorrent', 'transmission', 'deluge'] and inputHash:
|
if clientAgent in ['utorrent', 'transmission', 'deluge'] and inputHash:
|
||||||
# Delete torrent and torrentdata from Torrent client if processing was successful.
|
# Delete torrent and torrentdata from Torrent client if processing was successful.
|
||||||
if (int(nzbtomedia.CFG["Torrent"][
|
if (int(nzbtomedia.CFG["Torrent"][
|
||||||
"deleteOriginal"]) is 1 and result != 1) or nzbtomedia.USELINK == 'move': # if we move files, nothing to resume seeding.
|
"deleteOriginal"]) is 1 and result != 1) or nzbtomedia.USELINK == 'move': # if we move files, nothing to resume seeding.
|
||||||
logger.debug("Deleting torrent %s from %s" % (inputName, clientAgent))
|
logger.debug("Deleting torrent %s from %s" % (inputName, clientAgent))
|
||||||
if clientAgent == 'utorrent' and TorrentClass != "":
|
if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.removedata(inputHash)
|
nzbtomedia.TORRENT_CLASS.removedata(inputHash)
|
||||||
TorrentClass.remove(inputHash)
|
nzbtomedia.TORRENT_CLASS.remove(inputHash)
|
||||||
if clientAgent == 'transmission' and TorrentClass != "":
|
if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.remove_torrent(inputID, True)
|
nzbtomedia.TORRENT_CLASS.remove_torrent(inputID, True)
|
||||||
if clientAgent == 'deluge' and TorrentClass != "":
|
if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.core.remove_torrent(inputID, True)
|
nzbtomedia.TORRENT_CLASS.core.remove_torrent(inputID, True)
|
||||||
# we always want to resume seeding, for now manually find out what is wrong when extraction fails
|
# we always want to resume seeding, for now manually find out what is wrong when extraction fails
|
||||||
else:
|
else:
|
||||||
logger.debug("Starting torrent %s in %s" % (inputName, clientAgent))
|
logger.debug("Starting torrent %s in %s" % (inputName, clientAgent))
|
||||||
if clientAgent == 'utorrent' and TorrentClass != "":
|
if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.start(inputHash)
|
nzbtomedia.TORRENT_CLASS.start(inputHash)
|
||||||
if clientAgent == 'transmission' and TorrentClass != "":
|
if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.start_torrent(inputID)
|
nzbtomedia.TORRENT_CLASS.start_torrent(inputID)
|
||||||
if clientAgent == 'deluge' and TorrentClass != "":
|
if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
TorrentClass.core.resume_torrent([inputID])
|
nzbtomedia.TORRENT_CLASS.core.resume_torrent([inputID])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
def find_download(clientAgent, download_id):
|
def find_download(clientAgent, download_id):
|
||||||
tc = create_torrent_class(clientAgent)
|
|
||||||
|
|
||||||
logger.debug("Searching for Download on %s ..." % (clientAgent))
|
logger.debug("Searching for Download on %s ..." % (clientAgent))
|
||||||
if clientAgent == 'utorrent':
|
if clientAgent == 'utorrent':
|
||||||
torrents = tc.list()[1]['torrents']
|
torrents = nzbtomedia.TORRENT_CLASS.list()[1]['torrents']
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
if download_id in torrent:
|
if download_id in torrent:
|
||||||
return True
|
return True
|
||||||
if clientAgent == 'transmission':
|
if clientAgent == 'transmission':
|
||||||
torrents = tc.get_torrents()
|
torrents = nzbtomedia.TORRENT_CLASS.get_torrents()
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
hash = torrent.hashString
|
hash = torrent.hashString
|
||||||
if hash == download_id:
|
if hash == download_id:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue