diff --git a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py index ba134decd2..b24f34feb4 100644 --- a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py +++ b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py @@ -59,7 +59,7 @@ if sabNzbdLaunch: sabNzbdApiKey = sabConfiguration['misc']['api_key'] sabNzbdUser = sabConfiguration['misc']['username'] sabNzbdPass = sabConfiguration['misc']['password'] - sabNzbdQueue = 'http://' + sabNzbdAddress + '/sabnzbd/api?mode=queue&output=xml&apikey=' + sabNzbdApiKey + '&ma_username=' + sabNzbdUser + '&ma_password=' + sabNzbdUser + sabNzbdQueue = 'http://' + sabNzbdAddress + '/api?mode=queue&output=xml&apikey=' + sabNzbdApiKey + '&ma_username=' + sabNzbdUser + '&ma_password=' + sabNzbdPass # start checking SABnzbd for activity and prevent sleeping if necessary socket.setdefaulttimeout(timeout) @@ -83,29 +83,30 @@ while (not xbmc.abortRequested): wakeHourIdx = int(__settings__.getSetting('SABNZBD_WAKE_AT')) # check if SABnzbd is downloading - sabIsActive = False - req = urllib2.Request(sabNzbdQueue) - try: handle = urllib2.urlopen(req) - except IOError, e: - xbmc.log('SABnzbd-Suite: could not determine SABnzbds status', level=xbmc.LOGERROR) - else: - queue = handle.read() - handle.close() - sabIsActive = (queue.find('Downloading') >= 0) + if shouldKeepAwake: + sabIsActive = False + req = urllib2.Request(sabNzbdQueue) + try: handle = urllib2.urlopen(req) + except IOError, e: + xbmc.log('SABnzbd-Suite: could not determine SABnzbds status', level=xbmc.LOGERROR) + else: + queue = handle.read() + handle.close() + sabIsActive = (queue.find('Downloading') >= 0) - # reset idle timer when we're close to idle sleep/shutdown - if (shouldKeepAwake and sabIsActive): - response = xbmc.executehttpapi("GetGUISetting(0;powermanagement.shutdowntime)").replace('
  • ','') - shutdownTime = int(response) * 60 - idleTime = xbmc.getGlobalIdleTime() - timeToShutdown = shutdownTime - idleTime + # reset idle timer when we're close to idle sleep/shutdown + if sabIsActive: + response = xbmc.executehttpapi("GetGUISetting(0;powermanagement.shutdowntime)").replace('
  • ','') + shutdownTime = int(response) * 60 + idleTime = xbmc.getGlobalIdleTime() + timeToShutdown = shutdownTime - idleTime - if (sabIsActive and timeToShutdown <= checkInterval - timeout): - xbmc.log('SABnzbd-Suite: still downloading. Resetting XBMC idle timer.') - xbmc.executehttpapi("SendKey(0xF000)") + if (timeToShutdown <= checkInterval - timeout): + xbmc.log('SABnzbd-Suite: still downloading. Resetting XBMC idle timer.') + xbmc.executehttpapi("SendKey(0xF000)") # calculate and set the time to wake up at (if any) - if (wakePeriodically): + if wakePeriodically: wakeHour = wakeHourIdx * 2 + 1 timeOfDay = datetime.time(hour=wakeHour) now = datetime.datetime.now()