From 23afb9c70ba1a43f567e95435ec2dcce2065f9a6 Mon Sep 17 00:00:00 2001 From: jumpmanjay Date: Wed, 21 Sep 2016 09:17:31 -0500 Subject: [PATCH] add function to check whether SD DVR functionality is enabled --- Contents/Services/Shared Code/PyHDHR.pys | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Contents/Services/Shared Code/PyHDHR.pys b/Contents/Services/Shared Code/PyHDHR.pys index dbf4a85..98295d1 100644 --- a/Contents/Services/Shared Code/PyHDHR.pys +++ b/Contents/Services/Shared Code/PyHDHR.pys @@ -705,6 +705,8 @@ class PyHDHR: LastDiscover = 0 LastRecordedDiscover = 0 RecordedPrograms = {} + SDDVREnabled = False + SDDVRDiscover = 0 def __init__(self): return @@ -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: