Skip to content

Commit 1d6b46e

Browse files
authored
Merge pull request #64 from zynine-/zynine-autodiscover-option
1.1.3 autodiscover option
2 parents c67f185 + 30b7f83 commit 1d6b46e

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

Contents/Code/__init__.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from DumbTools import DumbPrefs
1313

1414
DEBUGMODE = True
15-
TITLE = 'HDHR Viewer 2 (1.1.2)'
15+
TITLE = 'HDHR Viewer 2 (1.1.3)'
1616
PREFIX = '/video/hdhrv2'
17-
VERSION = '1.1.2'
17+
VERSION = '1.1.3'
1818

1919
#GRAPHICS
2020
ART = 'art-default.jpg'
@@ -38,6 +38,7 @@
3838
PREFS_VCODEC = 'videocodec'
3939
PREFS_ACODEC = 'audiocodec'
4040
PREFS_ICONDIR = 'icon_directory'
41+
PREFS_AUTODISCOVER = 'autodiscover'
4142

4243
#XMLTV Modes
4344
XMLTV_MODE_RESTAPI = 'restapi'
@@ -1387,28 +1388,29 @@ def __init__(self):
13871388
# Auto Discover devices
13881389
def autoDiscover(self):
13891390
cacheTime=None
1390-
try:
1391-
response = xstr(HTTP.Request(URL_HDHR_DISCOVER_DEVICES,timeout=TIMEOUT,cacheTime=cacheTime))
1392-
JSONdevices = JSON.ObjectFromString(''.join(response.splitlines()))
1393-
1394-
for device in JSONdevices:
1395-
StorageURL = device.get('StorageURL')
1396-
LineupURL = device.get('LineupURL')
1397-
1398-
if LineupURL is not None:
1399-
if not xany(d['LocalIP']==device['LocalIP'] for d in self.tunerDevices):
1400-
device['autoDiscover'] = True
1401-
logInfo('Adding auto discovered tuner: '+device['LocalIP'])
1402-
self.tunerDevices.append(device)
1403-
else:
1404-
logInfo('Auto discovered tuner skipped (duplicate): '+device['LocalIP'])
1405-
1406-
#future
1407-
if StorageURL is not None:
1408-
self.storageServers.append(device)
1391+
if Prefs[PREFS_AUTODISCOVER]:
1392+
try:
1393+
response = xstr(HTTP.Request(URL_HDHR_DISCOVER_DEVICES,timeout=TIMEOUT,cacheTime=cacheTime))
1394+
JSONdevices = JSON.ObjectFromString(''.join(response.splitlines()))
1395+
1396+
for device in JSONdevices:
1397+
StorageURL = device.get('StorageURL')
1398+
LineupURL = device.get('LineupURL')
1399+
1400+
if LineupURL is not None:
1401+
if not xany(d['LocalIP']==device['LocalIP'] for d in self.tunerDevices):
1402+
device['autoDiscover'] = True
1403+
logInfo('Adding auto discovered tuner: '+device['LocalIP'])
1404+
self.tunerDevices.append(device)
1405+
else:
1406+
logInfo('Auto discovered tuner skipped (duplicate): '+device['LocalIP'])
14091407

1410-
except Exception as inst:
1411-
logError('Devices.autoDiscover(): '+strError(inst))
1408+
#future
1409+
if StorageURL is not None:
1410+
self.storageServers.append(device)
1411+
except Exception as inst:
1412+
logError('Devices.autoDiscover(): '+strError(inst))
1413+
14121414

14131415
# Get manual tuners listed in Settings
14141416
def manualTuner(self):

Contents/DefaultPrefs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"label": "HDHomeRun IP",
66
"default": "auto"
77
},
8+
{
9+
"id": "autodiscover",
10+
"type": "bool",
11+
"label": "Enable Auto Discover",
12+
"default": "true"
13+
},
814
{
915
"id": "xmltv_mode",
1016
"type": "enum",

0 commit comments

Comments
 (0)