def upload_file(url, fp):
 try:
  fp = unicoder(fp).encode('utf-8')
  fp = urllib.quote_plus(fp)
  url = ('%s&mode=addlocalfile&name=%s' % (url, fp))
  apikey = cfg.api_key()
  if (apikey and ('apikey' not in url)):
   url = ('%s&apikey=%s' % (url, apikey))
  if ('apikey' not in url):
   username = cfg.username()
   password = cfg.password()
   if (username and password):
    url = ('%s&ma_username=%s&ma_password=%s' % (url, username, password))
  sabnzbd.newsunpack.get_from_url(url)
 except:
  logging.error('Failed to upload file: %s', fp)
  logging.info('Traceback: ', exc_info=True)

def upload_file ( url , fp ) : try : fp = unicoder ( fp ) . encode ( 'utf-8' ) fp = urllib . quote_plus ( fp ) url = ( '%s&mode=addlocalfile&name=%s' % ( url , fp ) ) apikey = cfg . api_key ( ) if ( apikey and ( 'apikey' not in url ) ) : url = ( '%s&apikey=%s' % ( url , apikey ) ) if ( 'apikey' not in url ) : username = cfg . username ( ) password = cfg . password ( ) if ( username and password ) : url = ( '%s&ma_username=%s&ma_password=%s' % ( url , username , password ) ) sabnzbd . newsunpack . get_from_url ( url ) except : logging . error ( 'Failed to upload file: %s' , fp ) logging . info ( 'Traceback: ' , exc_info = True )
function for uploading nzbs to a running sabnzbd instance .