Exemple #1
0
 def get_categories(self):
     self.logger.debug("Sending categories request to sabnzbd")
     f = self.get_sab()
     f.add({"mode": "get_cats", "output": "json"})
     try:
         r = requests.get(f.tostr(), verify=False, timeout=15)
         r.raise_for_status()
         return r.json()["categories"]
     except (SSLError, HTTPError, ConnectionError, ReadTimeout, InvalidSchema, MissingSchema):
         self.logger.exception("Error while trying to connect to sabnzbd with URL %s" % f.url)
         raise DownloaderException("Unable to contact SabNZBd")
Exemple #2
0
    def get_categories(self):
        self.logger.debug("Sending categories request to nzbget")
        try:
            rpc = self.get_rpc()
            config = rpc.config()
            categories = []
            for i in config:
                if "Category" in i["Name"] and "Name" in i["Name"]:
                    categories.append(i["Value"])
            return categories

        except socket.error as e:
            self.logger.debug(str(e))
            self.logger.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
            raise DownloaderException("Unable to contact NZBGet")
        
        except xmlrpc.client.ProtocolError as e:
            if e.errcode == 401:
                self.logger.error('Wrong credentials')
            else:
                self.logger.error('Protocol error: %s', e)
            raise DownloaderException("Unable to contact NZBGet")
Exemple #3
0
    def get_sab(self, url=None, apikey=None, username=None, password=None):
        if url is None:
            url = self.setting.url
        if apikey is None:
            apikey = self.setting.apikey
        if username is None:
            username = self.setting.username
        if password is None:
            password = self.setting.password
        f = furl(url)
        f.path.add("api")
        if apikey:
            f.add({"apikey": apikey})
        elif username and password:
            pass
        else:
            raise DownloaderException("Neither API key nor username/password provided")
        f.add({"output": "json"})

        return f