This commit is contained in:
nivong 2013-01-29 06:24:52 -08:00
commit 12d3bf38c0
2 changed files with 18 additions and 69 deletions

View file

@ -42,8 +42,6 @@ class AuthURLOpener(urllib.FancyURLopener):
def processEpisode(dirName, nzbName=None, failed=False): def processEpisode(dirName, nzbName=None, failed=False):
status = int(failed)
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg") configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg")
print "Loading config from", configFilename print "Loading config from", configFilename
@ -60,7 +58,6 @@ def processEpisode(dirName, nzbName=None, failed=False):
print "Could not read configuration file: ", str(e) print "Could not read configuration file: ", str(e)
sys.exit(1) sys.exit(1)
watch_dir = ""
host = config.get("SickBeard", "host") host = config.get("SickBeard", "host")
port = config.get("SickBeard", "port") port = config.get("SickBeard", "port")
username = config.get("SickBeard", "username") username = config.get("SickBeard", "username")
@ -75,46 +72,15 @@ def processEpisode(dirName, nzbName=None, failed=False):
except ConfigParser.NoOptionError: except ConfigParser.NoOptionError:
web_root = "" web_root = ""
try:
watch_dir = config.get("SickBeard", "watch_dir")
except ConfigParser.NoOptionError:
watch_dir = ""
try:
failed_fork = int(config.get("SickBeard", "failed_fork"))
except (ConfigParser.NoOptionError, ValueError):
failed_fork = 0
#allows us to specify the default watch directory and call the postproecssing on another PC with different directory structure.
if watch_dir != "":
dirName = watch_dir
params = {} params = {}
params['quiet'] = 1 params['quiet'] = 1
# if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git params['dirName'] = dirName
if failed_fork: if nzbName != None:
params['dirName'] = dirName params['nzbName'] = nzbName
if nzbName != None:
params['nzbName'] = nzbName
params['failed'] = failed
if status:
print "The download failed. Sending 'failed' process request to SickBeard's failed branch"
else:
print "The download succeeded. Sending process request to SickBeard's failed branch"
# this is our default behaviour to work with the standard Master branch of SickBeard params['failed'] = failed
else:
params['dir'] = dirName
if nzbName != None:
params['nzbName'] = nzbName
# the standard Master bamch of SickBeard cannot process failed downloads. So Exit here.
if status:
print "The download failed. Nothing to process"
sys.exit()
else:
print "The download succeeded. Sending process request to SickBeard"
myOpener = AuthURLOpener(username, password) myOpener = AuthURLOpener(username, password)

View file

@ -17,39 +17,22 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
#
# Edited by Clinton Hall to prevent processing of failed downloads.
# Also added suppot for NZBGet. With help from thorli
import sys import sys
import autoProcessTV import autoProcessTV
print "nzbToSickBeard V4.0" if len(sys.argv) < 8:
print "Not enough arguments received from SABnzbd. Please update it."
# SABnzbd sys.exit()
if len(sys.argv) == 8:
# SABnzbd argv:
# 1 The final directory of the job (full path)
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
print "Script triggered from SABnzbd, starting autoProcessTV..."
autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7])
# NZBGet
elif len(sys.argv) == 4:
# 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
print "Script triggered from NZBGet, starting autoProcessTV..."
autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3])
else: else:
print "Invalid number of arguments received from client." autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7])
sys.exit()
# SABnzbd argv:
# 1 The final directory of the job (full path)
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21