diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 2621c4f9..ff7cf106 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -95,10 +95,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, uniquePath = 1 if clientAgent != 'manual': - try: - nzbtomedia.pause_torrent(clientAgent, inputHash, inputID, inputName) - except: - logger.warning("Failed to pause torrent %s in %s" % (inputName, clientAgent)) + nzbtomedia.pause_torrent(clientAgent, inputHash, inputID, inputName) if uniquePath: outputDestination = os.path.normpath( @@ -224,20 +221,15 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, if clientAgent != 'manual': logger.error( "A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding") - try: - nzbtomedia.resume_torrent(clientAgent, inputHash, inputID, inputName) - except: - logger.warning("Failed to resume torrent %s in %s" % (inputName, clientAgent)) + nzbtomedia.resume_torrent(clientAgent, inputHash, inputID, inputName) + else: if clientAgent != 'manual': # update download status in our DB nzbtomedia.update_downloadInfoStatus(inputName, 1) # remove torrent - try: - nzbtomedia.remove_torrent(clientAgent, inputHash, inputID, inputName) - except: - logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent)) + nzbtomedia.remove_torrent(clientAgent, inputHash, inputID, inputName) if not sectionName == 'UserScript': # for user script, we assume this is cleaned by the script or option USER_SCRIPT_CLEAN # cleanup our processing folders of any misc unwanted files and empty directories diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index ab7f1ae6..16f8e5c9 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -737,42 +737,44 @@ def create_torrent_class(clientAgent): def pause_torrent(clientAgent, inputHash, inputID, inputName): logger.debug("Stopping torrent %s in %s while processing" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.stop(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.stop_torrent(inputID) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.pause_torrent([inputID]) - - time.sleep(5) + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.stop(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.stop_torrent(inputID) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.pause_torrent([inputID]) + time.sleep(5) + except: + logger.warning("Failed to stop torrent %s in %s" % (inputName, clientAgent)) def resume_torrent(clientAgent, inputHash, inputID, inputName): logger.debug("Starting torrent %s in %s" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.start(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.start_torrent(inputID) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.resume_torrent([inputID]) - - time.sleep(5) + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.start(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.start_torrent(inputID) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.resume_torrent([inputID]) + time.sleep(5) + except: + logger.warning("Failed to start torrent %s in %s" % (inputName, clientAgent)) def remove_torrent(clientAgent, inputHash, inputID, inputName): if nzbtomedia.DELETE_ORIGINAL == 1 or nzbtomedia.USELINK == 'move': logger.debug("Deleting torrent %s from %s" % (inputName, clientAgent)) - - if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.removedata(inputHash) - nzbtomedia.TORRENT_CLASS.remove(inputHash) - if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.remove_torrent(inputID, True) - if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": - nzbtomedia.TORRENT_CLASS.core.remove_torrent(inputID, True) - - time.sleep(5) - + try: + if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.removedata(inputHash) + nzbtomedia.TORRENT_CLASS.remove(inputHash) + if clientAgent == 'transmission' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.remove_torrent(inputID, True) + if clientAgent == 'deluge' and nzbtomedia.TORRENT_CLASS != "": + nzbtomedia.TORRENT_CLASS.core.remove_torrent(inputID, True) + time.sleep(5) + except: + logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent)) else: resume_torrent(clientAgent, inputHash, inputID, inputName)