mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
SABnzdb-Suite fix keep awake option.
This commit is contained in:
parent
0991e2a7ab
commit
691852e66d
@ -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('<status>Downloading</status>') >= 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('<status>Downloading</status>') >= 0)
|
||||
|
||||
# reset idle timer when we're close to idle sleep/shutdown
|
||||
if (shouldKeepAwake and sabIsActive):
|
||||
response = xbmc.executehttpapi("GetGUISetting(0;powermanagement.shutdowntime)").replace('<li>','')
|
||||
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('<li>','')
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user