Permalink
Browse files

SABNzbd https backup

  • Loading branch information...
1 parent 5ade3d7 commit 53fcb3627ae8f2b0b3f5a4c98a2dff9a7711a07d @RuudBurger RuudBurger committed Jul 27, 2010
Showing with 18 additions and 20 deletions.
  1. +18 −19 app/lib/sabNzbd.py
  2. +0 −1 todo.md
View
@@ -1,5 +1,6 @@
import logging
-import urllib
+from urllib import urlencode
+import urllib2
log = logging.getLogger(__name__)
@@ -20,7 +21,7 @@ def send(self, nzb):
log.error("Config properties are not filled in correctly.")
return False
- url = 'http://' + self.conf('host') + "/sabnzbd/api?" + urllib.urlencode({
+ url = 'http://' + self.conf('host') + "/sabnzbd/api?" + urlencode({
'ma_username': self.conf('username'),
'ma_password': self.conf('password'),
'apikey': self.conf('apikey'),
@@ -32,32 +33,30 @@ def send(self, nzb):
log.info("URL: " + url)
try:
- r = urllib.urlopen(url)
+ r = urllib2.urlopen(url, timeout = 10)
except:
- log.error("Unable to connect to SAB.")
- return False
-
- if r == None:
+ try:
+ # try https
+ url = url.replace('http:', 'https:')
+ r = urllib2.urlopen(url, timeout = 10)
+ except:
+ log.error("Unable to connect to SAB.")
+ return False
+
+ result = r.read().strip()
+ if not result:
log.error("SABnzbd didn't return anything.")
return False
- result = r.readlines()
- if len(result) == 0:
- log.error("SABnzbd didn't return anything.")
- return False
-
- sabText = result[0].strip()
-
- log.info("Result text from SAB: " + sabText)
-
- if sabText == "ok":
+ log.debug("Result text from SAB: " + result)
+ if result == "ok":
log.info("NZB sent to SAB successfully.")
return True
- elif sabText == "Missing authentication":
+ elif result == "Missing authentication":
log.error("Incorrect username/password.")
return False
else:
- log.error("Unknown error: " + sabText)
+ log.error("Unknown error: " + result)
return False
def isDisabled(self):
View
@@ -1,5 +1,4 @@
* Find providers that don't need login/registration
-* SABnzbd SSL option to include HTTPS
* Edit movie info
Userscript:

0 comments on commit 53fcb36

Please sign in to comment.