Exemple #1
0
def _load_json(url):
    sabutils.log("SABnzbd: _load_json: url: %s" % url)
    try:
        out = json.loads(_load_url(url))
    except:
        sabutils.log("SABnzbd: _load_json: malformed json from url: %s" % url)
        sabutils.notification("SABnzbd malformed json")
        return None
    return out
Exemple #2
0
def _load_xml(url):
    sabutils.log("SABnzbd: _load_xml: ")
    try:
        out = parseString(_load_url(url))
    except:
        sabutils.log("SABnzbd: _load_xml: malformed xml from url: %s" % url)
        sabutils.notification("SABnzbd malformed xml")
        return None
    return out
Exemple #3
0
 def self_test(self):
     url = self.baseurl + "&mode=version&output=xml"
     if _load_url(url) is None:
         sabutils.log("SABnzbd: setup_streaming: unable to conncet to SABnzbd: %s" % url)
         return "ip"
     url = self.baseurl + "&mode=get_config&section=misc&keyword=allow_streaming&output=xml"
     doc = _load_xml(url)
     if doc.getElementsByTagName("result"):
         return "apikey"
     return "ok"
Exemple #4
0
 def nzf_id_list(self, sab_nzo_id, file_list):
     url = self.baseurl + "&mode=get_files&output=xml&value=" + str(sab_nzo_id)
     doc = _load_xml(url)
     sab_nzf_id_list = []
     file_nzf = dict()
     if doc:
         if doc.getElementsByTagName("file"):
             for file in doc.getElementsByTagName("file"):
                 filename = get_node_value(file, "filename")
                 status = get_node_value(file, "status")
                 if status == "active":
                     file_nzf[filename] = get_node_value(file, "nzf_id")
     for filename in file_list:
         try:
             sab_nzf_id_list.append(file_nzf[filename])
         except:
             sabutils.log("SABnzbd: nzf_id_list: unable to find sab_nzf_id for: %s" % filename)
     return sab_nzf_id_list
Exemple #5
0
def _load_url(url):
        sabutils.log("SABnzbd: _load_url: ")
        return sabutils.load_url(url)
Exemple #6
0
 def _sabResponse(self, url):
     responseMessage = _load_url(url)
     sabutils.log("SABnzbd: _sabResponse message: %s" % responseMessage)
     sabutils.log("SABnzbd: _sabResponse from url: %s" % url)
     return responseMessage