mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Added SickBeard files
Includes modified sabToSickBeard (now nzbToSickBeard) that supports NZBGet
This commit is contained in:
parent
23fbe0bbc9
commit
be059e6cf3
3 changed files with 168 additions and 0 deletions
7
autoProcessTV.cfg.sample
Normal file
7
autoProcessTV.cfg.sample
Normal file
|
@ -0,0 +1,7 @@
|
|||
[SickBeard]
|
||||
host=localhost
|
||||
port=8081
|
||||
username=
|
||||
password=
|
||||
web_root=
|
||||
ssl=0
|
108
autoProcessTV.py
Normal file
108
autoProcessTV.py
Normal file
|
@ -0,0 +1,108 @@
|
|||
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||
# URL: http://code.google.com/p/sickbeard/
|
||||
#
|
||||
# This file is part of Sick Beard.
|
||||
#
|
||||
# Sick Beard is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Sick Beard is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sys
|
||||
import urllib
|
||||
import os.path
|
||||
import ConfigParser
|
||||
|
||||
class AuthURLOpener(urllib.FancyURLopener):
|
||||
def __init__(self, user, pw):
|
||||
self.username = user
|
||||
self.password = pw
|
||||
self.numTries = 0
|
||||
urllib.FancyURLopener.__init__(self)
|
||||
|
||||
def prompt_user_passwd(self, host, realm):
|
||||
if self.numTries == 0:
|
||||
self.numTries = 1
|
||||
return (self.username, self.password)
|
||||
else:
|
||||
return ('', '')
|
||||
|
||||
def openit(self, url):
|
||||
self.numTries = 0
|
||||
return urllib.FancyURLopener.open(self, url)
|
||||
|
||||
|
||||
def processEpisode(dirName, nzbName=None, status=0):
|
||||
|
||||
if status > 0:
|
||||
print "the download failed. nothing to process"
|
||||
sys.exit()
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg")
|
||||
print "Loading config from", configFilename
|
||||
|
||||
if not os.path.isfile(configFilename):
|
||||
print "ERROR: You need an autoProcessTV.cfg file - did you rename and edit the .sample?"
|
||||
sys.exit(-1)
|
||||
|
||||
try:
|
||||
fp = open(configFilename, "r")
|
||||
config.readfp(fp)
|
||||
fp.close()
|
||||
except IOError, e:
|
||||
print "Could not read configuration file: ", str(e)
|
||||
sys.exit(1)
|
||||
|
||||
host = config.get("SickBeard", "host")
|
||||
port = config.get("SickBeard", "port")
|
||||
username = config.get("SickBeard", "username")
|
||||
password = config.get("SickBeard", "password")
|
||||
try:
|
||||
ssl = int(config.get("SickBeard", "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
|
||||
try:
|
||||
web_root = config.get("SickBeard", "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = ""
|
||||
|
||||
params = {}
|
||||
|
||||
params['quiet'] = 1
|
||||
|
||||
params['dir'] = dirName
|
||||
if nzbName != None:
|
||||
params['nzbName'] = nzbName
|
||||
|
||||
myOpener = AuthURLOpener(username, password)
|
||||
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
protocol = "http://"
|
||||
|
||||
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(params)
|
||||
|
||||
print "Opening URL:", url
|
||||
|
||||
try:
|
||||
urlObj = myOpener.openit(url)
|
||||
except IOError, e:
|
||||
print "Unable to open URL: ", str(e)
|
||||
sys.exit(1)
|
||||
|
||||
result = urlObj.readlines()
|
||||
for line in result:
|
||||
print line
|
||||
|
53
nzbToSickBeard.py
Normal file
53
nzbToSickBeard.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||
# URL: http://code.google.com/p/sickbeard/
|
||||
#
|
||||
# This file is part of Sick Beard.
|
||||
#
|
||||
# Sick Beard is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Sick Beard is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# 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 autoProcessTV
|
||||
|
||||
# SABnzbd
|
||||
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) == 3:
|
||||
# NZBGet argv:
|
||||
# 1 The final directory of the job (full path)
|
||||
# 2 The original name of the NZB file
|
||||
# From NZBGet only successful downloads are triggered so status is set to "0"
|
||||
print "Script triggered from NZBGet, starting autoProcessTV..."
|
||||
|
||||
autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], 0)
|
||||
|
||||
else:
|
||||
print "Invalid number of arguments received from client."
|
||||
sys.exit()
|
Loading…
Add table
Add a link
Reference in a new issue