Skip to content

Commit

Permalink
Merge pull request #64 from zynine-/zynine-autodiscover-option
Browse files Browse the repository at this point in the history
1.1.3 autodiscover option
  • Loading branch information
zynine- authored Apr 29, 2018
2 parents c67f185 + 30b7f83 commit 1d6b46e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
48 changes: 25 additions & 23 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from DumbTools import DumbPrefs

DEBUGMODE = True
TITLE = 'HDHR Viewer 2 (1.1.2)'
TITLE = 'HDHR Viewer 2 (1.1.3)'
PREFIX = '/video/hdhrv2'
VERSION = '1.1.2'
VERSION = '1.1.3'

#GRAPHICS
ART = 'art-default.jpg'
Expand All @@ -38,6 +38,7 @@
PREFS_VCODEC = 'videocodec'
PREFS_ACODEC = 'audiocodec'
PREFS_ICONDIR = 'icon_directory'
PREFS_AUTODISCOVER = 'autodiscover'

#XMLTV Modes
XMLTV_MODE_RESTAPI = 'restapi'
Expand Down Expand Up @@ -1387,28 +1388,29 @@ def __init__(self):
# Auto Discover devices
def autoDiscover(self):
cacheTime=None
try:
response = xstr(HTTP.Request(URL_HDHR_DISCOVER_DEVICES,timeout=TIMEOUT,cacheTime=cacheTime))
JSONdevices = JSON.ObjectFromString(''.join(response.splitlines()))

for device in JSONdevices:
StorageURL = device.get('StorageURL')
LineupURL = device.get('LineupURL')

if LineupURL is not None:
if not xany(d['LocalIP']==device['LocalIP'] for d in self.tunerDevices):
device['autoDiscover'] = True
logInfo('Adding auto discovered tuner: '+device['LocalIP'])
self.tunerDevices.append(device)
else:
logInfo('Auto discovered tuner skipped (duplicate): '+device['LocalIP'])

#future
if StorageURL is not None:
self.storageServers.append(device)
if Prefs[PREFS_AUTODISCOVER]:
try:
response = xstr(HTTP.Request(URL_HDHR_DISCOVER_DEVICES,timeout=TIMEOUT,cacheTime=cacheTime))
JSONdevices = JSON.ObjectFromString(''.join(response.splitlines()))

for device in JSONdevices:
StorageURL = device.get('StorageURL')
LineupURL = device.get('LineupURL')

if LineupURL is not None:
if not xany(d['LocalIP']==device['LocalIP'] for d in self.tunerDevices):
device['autoDiscover'] = True
logInfo('Adding auto discovered tuner: '+device['LocalIP'])
self.tunerDevices.append(device)
else:
logInfo('Auto discovered tuner skipped (duplicate): '+device['LocalIP'])

except Exception as inst:
logError('Devices.autoDiscover(): '+strError(inst))
#future
if StorageURL is not None:
self.storageServers.append(device)
except Exception as inst:
logError('Devices.autoDiscover(): '+strError(inst))


# Get manual tuners listed in Settings
def manualTuner(self):
Expand Down
6 changes: 6 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"label": "HDHomeRun IP",
"default": "auto"
},
{
"id": "autodiscover",
"type": "bool",
"label": "Enable Auto Discover",
"default": "true"
},
{
"id": "xmltv_mode",
"type": "enum",
Expand Down

0 comments on commit 1d6b46e

Please sign in to comment.