Esempio n. 1
0
 def file_list_position(self, sab_nzo_id, sab_nzf_id, position):
     action = { -1 : 'Delete',
                 0 : 'Top',
                 1 : 'Up',
                 2 : 'Down',
                 3 : 'Bottom'}
     url = "http://" + self.ip + ":" + self.port + "/sabnzbd/nzb/" + sab_nzo_id + "/bulk_operation?session=" \
           + self.apikey + "&action_key=" + action[position]
     for nzf_id in sab_nzf_id:
         url = url + "&" + nzf_id + "=on"
     sabutils.load_url(url, None, "SABnzbd failed moving file to top of queue")
     return
Esempio n. 2
0
def post(path, apikey, url, **kwargs):
    output = kwargs.get('output', 'xml')
    cat = kwargs.get('cat', 'Default')
    priority = kwargs.get('priority', '-100')
    pp = kwargs.get('pp', '-1')
    nzbname = kwargs.get('nzbname', '')
    form = MultiPartForm() 
    nzb_data = sabutils.read(path, 'rb')
    form.add_field('apikey', apikey)
    form.add_field('mode', 'addfile')
    form.add_field('output', output)
    form.add_field('cat', cat)
    form.add_field('priority', priority)
    form.add_field('pp', pp)
    form.add_field('nzbname', nzbname)
    form.add_file('nzbfile', path, fileHandle=StringIO(nzb_data))
    req = urllib2.Request(url)
    body = str(form)
    req.add_header('Content-type', form.get_content_type())
    req.add_header('Content-length', len(body))
    req.add_data(body)
    # Dont care about the response
    sabutils.load_url(url, req, "SABnzbd failed posting data")
    return "ok"
Esempio n. 3
0
def _load_url(url):
        sabutils.log("SABnzbd: _load_url: ")
        return sabutils.load_url(url)