Skip to content

Commit ec0cbc4

Browse files
committed
Add Tvh username-password ability
1 parent aeb07b4 commit ec0cbc4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

addon.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="script.module.tvh2kodi"
33
name="Tvheadend Setup for Kodi"
4-
version="1.6"
4+
version="1.7"
55
provider-name="edit4ever">
66
<requires>
77
<import addon="xbmc.python" version="2.6.0"/>
@@ -17,6 +17,8 @@
1717
<description>Tvh2Kodi gives access to the basic Tvheadend settings directly from the Kodi interface. This can be used in place of the Tvheadend web interface to get your Tvheadend backend server configured and running. It is also provides an easy way to scan for new services and channels and to configure your channel EPG sources.
1818

1919
* minimum version of Tvheadend is 4.2
20+
v1.7
21+
- add support for Tvh username-password
2022
v1.6
2123
- add backup and import of tvh userdata
2224
- add channel icon reset option

default.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import ast
1414
import zipfile
1515
import datetime
16+
#from requests.exceptions import HTTPError
17+
#from requests.exceptions import ConnectionError
1618

1719
plugin = Plugin()
1820
dialog = xbmcgui.Dialog()
@@ -37,8 +39,24 @@
3739
except:
3840
pass
3941

40-
tvh_url = xbmcaddon.Addon().getSetting('tvhurl')
4142
tvh_port = xbmcaddon.Addon().getSetting('tvhport')
43+
tvh_usern = xbmcaddon.Addon().getSetting('usern')
44+
tvh_passw = xbmcaddon.Addon().getSetting('passw')
45+
if tvh_usern != "" and tvh_passw != "":
46+
tvh_url = tvh_usern + ":" + tvh_passw + "@" + xbmcaddon.Addon().getSetting('tvhurl')
47+
else:
48+
tvh_url = xbmcaddon.Addon().getSetting('tvhurl')
49+
50+
try:
51+
check_url = 'http://' + tvh_url + ':' + tvh_port + '/api/status/connections'
52+
check_load = requests.get(check_url)
53+
check_status = check_load.raise_for_status()
54+
except requests.exceptions.HTTPError as err:
55+
dialog.ok("Tvheadend Access Error!", str(err), "", "Please check your username/password in settings.")
56+
except requests.exceptions.RequestException as e:
57+
dialog.ok("Tvheadend Access Error!", "Could not connect to Tvheadend server.", "Please check your Tvheadend server is running or check the IP and port configuration in the settings.")
58+
59+
4260
truefalse = ['true', 'false']
4361
enabledisable = ['Enabled', 'Disabled']
4462

resources/settings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<category label="32000">
44
<setting label="32010" type="ipaddress" id="tvhurl" default="127.0.0.1"/>
55
<setting label="32020" type="number" id="tvhport" default="9981"/>
6+
<setting label="32022" type="text" id="usern" default=""/>
7+
<setting label="32023" type="text" id="passw" default=""/>
8+
<setting label="" type="lsep" />
69
<setting label="32030" type="folder" id="dvrstorage" default="" option="writeable"/>
710
</category>
811
</settings>

0 commit comments

Comments
 (0)