Пример #1
0
    def sendToSabNzbd(self, params):        
        url = cleanHost(self.conf('host')) + "sabnzbd/api?" + urlencode(params)

        log.info("URL: " + url)

        try:
            r = urllib2.urlopen(url, timeout = 30)
        except:
            try:
                # try https
                url = url.replace('http:', 'https:')
                r = urllib2.urlopen(url, timeout = 30)
            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

        log.debug("Result text from SAB: " + result)
        if result == "ok":
            log.info("NZB sent to SAB successfully.")
            return True
        elif result == "Missing authentication":
            log.error("Incorrect username/password.")
            return False
        else:
            log.error("Unknown error: " + result)
            return False
Пример #2
0
    def send(self, nzb):
        log.info("Sending '%s' to SABnzbd." % nzb.name)

        if self.isDisabled():
            log.error("Config properties are not filled in correctly.")
            return False

        params = {
            'apikey': self.conf('apikey'),
            'cat': self.conf('category'),
            'mode': 'addurl',
            'name': nzb.url
        }

        if self.conf('username'):
            params['ma_username'] = self.conf('username')
        if self.conf('password'):
            params['ma_password'] = self.conf('password')

        url = cleanHost(self.conf('host')) + "sabnzbd/api?" + urlencode(params)

        log.info("URL: " + url)

        try:
            r = urllib2.urlopen(url, timeout = 30)
        except:
            try:
                # try https
                url = url.replace('http:', 'https:')
                r = urllib2.urlopen(url, timeout = 30)
            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

        log.debug("Result text from SAB: " + result)
        if result == "ok":
            log.info("NZB sent to SAB successfully.")
            return True
        elif result == "Missing authentication":
            log.error("Incorrect username/password.")
            return False
        else:
            log.error("Unknown error: " + result)
            return False
Пример #3
0
 def getUrl(self, type):
     return cleanHost(self.conf("host")) + "api?t=" + type
Пример #4
0
 def getUrl(self, type):
     return cleanHost(self.conf('host')) + 'api?t=' + type
Пример #5
0
    def send(self, nzb, imdbId=None):
        log.info("Sending '%s' to SABnzbd." % nzb.name)

        if self.isDisabled():
            log.error("Config properties are not filled in correctly.")
            return False
        
        if self.conf('ppDir') and imdbId:
            try:
                ppScriptFn = self.buildPp(imdbId, self.getPpFile())
            except:
                log.info("Failed to create post-processing script.")
                ppScriptFn = False
            if not ppScriptFn:
                pp = False
            else:
                pp = True
        else:
            pp = False

        params = {
            'apikey': self.conf('apikey'),
            'cat': self.conf('category'),
            'mode': 'addurl',
            'name': nzb.url
        }

        # sabNzbd complains about "invalid archive file" for newzbin urls 
        # added using addurl, works fine with addid
        if nzb.addbyid:
            params['mode'] = 'addid'

        if self.conf('username'):
            params['ma_username'] = self.conf('username')
        if self.conf('password'):
            params['ma_password'] = self.conf('password')
        if pp:
            params['script'] = ppScriptFn

        url = cleanHost(self.conf('host')) + "sabnzbd/api?" + urlencode(params)

        log.info("URL: " + url)

        try:
            r = urllib2.urlopen(url, timeout = 30)
        except:
            try:
                # try https
                url = url.replace('http:', 'https:')
                r = urllib2.urlopen(url, timeout = 30)
            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

        log.debug("Result text from SAB: " + result)
        if result == "ok":
            log.info("NZB sent to SAB successfully.")
            return True
        elif result == "Missing authentication":
            log.error("Incorrect username/password.")
            return False
        else:
            log.error("Unknown error: " + result)
            return False
Пример #6
0
 def getUrl(self, type):
     return cleanHost(self.conf('host')) + 'api?t=' + type
Пример #7
0
    def send(self, nzb, imdbId=None):
        log.info("Sending '%s' to SABnzbd." % nzb.name)

        if self.isDisabled():
            log.error("Config properties are not filled in correctly.")
            return False

        if self.conf('ppDir') and imdbId:
            try:
                ppScriptFn = self.buildPp(imdbId, self.getPpFile())
            except:
                log.info("Failed to create post-processing script.")
                ppScriptFn = False
            if not ppScriptFn:
                pp = False
            else:
                pp = True
        else:
            pp = False

        params = {
            'apikey': self.conf('apikey'),
            'cat': self.conf('category'),
            'mode': 'addurl',
            'name': nzb.url
        }

        # sabNzbd complains about "invalid archive file" for newzbin urls
        # added using addurl, works fine with addid
        if nzb.addbyid:
            params['mode'] = 'addid'

        if self.conf('username'):
            params['ma_username'] = self.conf('username')
        if self.conf('password'):
            params['ma_password'] = self.conf('password')
        if pp:
            params['script'] = ppScriptFn

        url = cleanHost(self.conf('host')) + "sabnzbd/api?" + urlencode(params)

        log.info("URL: " + url)

        try:
            r = urllib2.urlopen(url, timeout=30)
        except:
            try:
                # try https
                url = url.replace('http:', 'https:')
                r = urllib2.urlopen(url, timeout=30)
            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

        log.debug("Result text from SAB: " + result)
        if result == "ok":
            log.info("NZB sent to SAB successfully.")
            return True
        elif result == "Missing authentication":
            log.error("Incorrect username/password.")
            return False
        else:
            log.error("Unknown error: " + result)
            return False