Skip to content

Commit

Permalink
add function to check whether SD DVR functionality is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpmanjay committed Sep 21, 2016
1 parent 458d781 commit 23afb9c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Contents/Services/Shared Code/PyHDHR.pys
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ class PyHDHR:
LastDiscover = 0
LastRecordedDiscover = 0
RecordedPrograms = {}
SDDVREnabled = False
SDDVRDiscover = 0

def __init__(self):
return
Expand Down Expand Up @@ -935,6 +937,25 @@ class PyHDHR:
Log.Critical(e)
return False

def hasSDDVR(self,force=False):
if not force:
if time.time() - self.SDDVRDiscover < 60:
return self.SDDVREnabled

self.SDDVRDiscover = time.time()

try:
response = urllib2.urlopen(URL_DISCOVER,None,5)
data = json.loads(response.read())
for item in data:
if 'StorageID' in item:
self.SDDVREnabled = True
return True
except Exception as e:
Log.Critical("Exception in PyHDHR.hasSDDVR while attempting to load: "+str(URL_DISCOVER))
Log.Critical(e)
return self.SDDVREnabled

def discover(self,force=False):
if not force:
if time.time() - self.LastDiscover < 60:
Expand Down

0 comments on commit 23afb9c

Please sign in to comment.