Skip to content

Commit 131e484

Browse files
authored
Kodi 19 support
1 parent d4d0b8d commit 131e484

File tree

18 files changed

+85
-82
lines changed

18 files changed

+85
-82
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Desktop.ini
77

88
# python
99
*.pyo
10+
__pycache__

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 hyperion-project
3+
Copyright (c) 2021 hyperion-project
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

LICENSE.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Hyperion Control [![Total alerts](https://img.shields.io/lgtm/alerts/g/hyperion-project/hyperion.control.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/hyperion-project/hyperion.control/alerts/)
1+
# Hyperion Control fork for Kodi 19 (Matrix)
22

3-
Hyperion Control is an addon for Kodi Mediacenter that observes Kodi events (playing state, screensaver, ...). Based on these events you can control Hyperion components to enable or disable accordingly.
3+
This is a KodiMatrix ONLY fork of Hyperion Control which is an addon for Kodi Mediacenter that observes Kodi events (playing state, screensaver, ...). Based on these events you can control Hyperion components to enable or disable accordingly.
44

55
For example playing a video should enable screen capture, if you pause the video or you are at the Kodi menu the screen capture should be disabled to show a background effect as mood light
66

@@ -14,20 +14,8 @@ For example playing a video should enable screen capture, if you pause the video
1414

1515
### Installation
1616
- Download .zip from release page and use "Install from zip file" dialog at the Kodi addons section.
17-
- Download from the official Kodi Addon repository (NOT PUBLISHED)
18-
19-
### Possible Features
20-
- Track ip/port changes on startup and update accordingly (this works just if server detection was used to configure ip/port)
21-
22-
### Feedback
23-
- Please open a github issue with (detailed) feedback
24-
25-
### Contributing
26-
Contributions are welcome! Feel free to join us! We are looking always for people who wants to participate.
27-
[![Contributors](https://img.shields.io/github/contributors/hyperion-project/hyperion.control.svg)](https://github.com/hyperion-project/hyperion.control/graphs/contributors)
28-
29-
For an example, you can participate in the translation.
30-
[![Join Translation](https://img.shields.io/badge/POEditor-translate-green.svg)](https://poeditor.com/join/project/WauIsJeEx4)
3117

3218
### Credits
3319
- Dan Krause for the SSDP client
20+
- Paulchen-Panther for service development
21+
- brindosch for service development

addon.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="script.service.hyperion-control" name="Hyperion Control" version="1.0.1" provider-name="hyperion-project, brindosch">
2+
<addon id="script.service.hyperion-control" name="Hyperion Control" version="19.0.1" provider-name="hyperion-project">
33
<requires>
44
<import addon="xbmc.addon" version="17.0.0"/>
5-
<import addon="xbmc.python" version="2.25.0"/>
5+
<import addon="xbmc.python" version="3.0.0"/>
66
<import addon="script.module.simplejson" version="3.3.0"/>
77
<import addon="script.module.httplib2" version="0.8.0"/>
88
</requires>
@@ -18,11 +18,15 @@
1818
<language></language>
1919
<platform>all</platform>
2020
<license>MIT</license>
21-
<forum>https://forum.hyperion-project.org</forum>
21+
<forum>https://hyperion-project.org/forum</forum>
2222
<website>https://www.hyperion-project.org</website>
2323
<email></email>
24-
<source>https://github.com/hyperion-project</source>
24+
<source>https://github.com/hyperion-project/hyperion.control</source>
2525
<news>
26+
19.0.1
27+
- Kodi 19 support
28+
- minor cleanups and corrections
29+
2630
1.0.1
2731
- Fixed a crash with 3d mode @b-jesch
2832

@@ -33,8 +37,8 @@
3337
</news>
3438
<assets>
3539
<icon>resources/media/icon.png</icon>
36-
<fanart>resources/media/fanart.jpg</fanart>
37-
<screenshot>resources/media/fanart.jpg</screenshot>
40+
<fanart>resources/media/fanart.png</fanart>
41+
<screenshot>resources/media/screenshot-01.png</screenshot>
3842
</assets>
3943
</extension>
4044
</addon>

resources/lib/connection.py renamed to lib/connection.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from utils import log
1+
from lib.utils import log, bytesDecodeUtf8
2+
from lib.gui import notifyUser
23
import httplib2
4+
import simplejson as json
35

46
class Connection:
57
def __init__(self):
@@ -20,8 +22,14 @@ def updateURL(self, ip, port):
2022
self.__url = "http://"+ip+":"+str(port)+"/json-rpc"
2123

2224
def send(self, body):
25+
log("Send to: "+self.__url+" payload: "+body)
2326
try:
2427
response, content = self.__http.request(self.__url, 'POST', headers=self.__headers, body=body)
28+
jsonContent = json.loads(bytesDecodeUtf8(content))
29+
if not jsonContent["success"]:
30+
if jsonContent["error"] == "No Authorization":
31+
notifyUser("Error: No Authorization, API Token required")
32+
log("Error: "+jsonContent["error"])
2533
except:
2634
pass
2735

resources/lib/connection_ws.py renamed to lib/connection_ws.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from utils import log
2-
import xbmc, xbmcaddon, time
1+
from lib.utils import log
32
import websocket
43

54
class Connection:
65
def __init__(self):
7-
self.__url = "ws://192.168.0.12:19444"
6+
# self.__url = "ws://192.168.0.11:19446"
7+
# self.__url = "ws://192.168.0.12:19444"
8+
self.__url = "ws://192.168.0.13:19444"
89
self.__ip = "127.0.0.1"
10+
# self.__port = "19446"
911
self.__port = "19444"
1012
self.__connected = False
1113
self.__ws = websocket.WebSocketApp(url=self.__url , on_message = self.on_message, on_error = self.on_error, on_close = self.on_close, on_open = self.on_open)

resources/lib/gui.py renamed to lib/gui.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import xbmcgui
2-
import ssdp
3-
from utils import log, openSettings, getLS, getSetting, setSetting, getAddonVersion, getAddonChangelog, updateSavedAddonVersion
2+
import lib.ssdp as ssdp
3+
from lib.utils import openSettings, getLS, getSetting, setSetting, getAddonVersion, getAddonChangelog
44

55
def notifyUser(message,time=3000, icon=xbmcgui.NOTIFICATION_INFO):
66
xbmcgui.Dialog().notification('Hyperion Control', message.encode('utf-8'), icon, time)
@@ -37,7 +37,7 @@ def doSSDPDiscovery():
3737
if len(filteredResponse) > 1:
3838
selectedServer = xbmcgui.Dialog().select(getLS(32102), buildSelectList(ipPortUsnList))
3939
else:
40-
xbmcgui.Dialog().ok('Hyperion Control', getLS(32103), '-> '+ipPortUsnList[0]["ip"]+':'+str(ipPortUsnList[0]["port"]))
40+
xbmcgui.Dialog().ok('Hyperion Control', getLS(32103) + '[CR]' + ipPortUsnList[0]["ip"]+':'+str(ipPortUsnList[0]["port"]))
4141
selectedServer = 0
4242

4343
#check user input and push settings if valid
@@ -51,12 +51,12 @@ def doSSDPDiscovery():
5151
return
5252

5353
def doInitialWizard():
54-
if xbmcgui.Dialog().yesno('Hyperion Control',getLS(32100),getLS(32101)):
54+
if xbmcgui.Dialog().yesno('Hyperion Control',getLS(32100) + "[CR]" + getLS(32101)):
5555
doSSDPDiscovery()
5656
openSettings()
5757
return
5858

5959
def doChangelogDisplay():
6060
if getSetting('currAddonVersion') != getAddonVersion():
61-
updateSavedAddonVersion()
61+
# updateSavedAddonVersion()
6262
xbmcgui.Dialog().textviewer('Hyperion Control - Changelog', getAddonChangelog())

resources/lib/ssdp.py renamed to lib/ssdp.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
#
1818

1919
import socket
20-
import httplib
21-
import StringIO
20+
from .utils import log, bytesEncodeUtf8
21+
22+
import http.client
23+
24+
from io import BytesIO
2225

2326
class SSDPResponse(object):
24-
class _FakeSocket(StringIO.StringIO):
27+
class _FakeSocket(BytesIO):
2528
def makefile(self, *args, **kw):
2629
return self
2730
def __init__(self, response):
28-
r = httplib.HTTPResponse(self._FakeSocket(response))
31+
r = http.client.HTTPResponse(self._FakeSocket(response))
2932
r.begin()
3033
self.location = r.getheader("location")
3134
self.usn = r.getheader("usn")
@@ -47,11 +50,11 @@ def discover(service, timeout=3, retries=1, mx=2):
4750
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
4851
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
4952
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
50-
sock.sendto(message.format(*group, st=service, mx=mx), group)
53+
sock.sendto(bytesEncodeUtf8(message.format(*group, st=service, mx=mx)), group)
5154
while True:
5255
try:
5356
response = SSDPResponse(sock.recv(1024))
5457
responses[response.location] = response
5558
except socket.timeout:
5659
break
57-
return responses.values()
60+
return list(responses.values())

resources/lib/utils.py renamed to lib/utils.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import xbmc, xbmcaddon
22
import simplejson as json
3+
import sys
34

45
ADDON = xbmcaddon.Addon()
56
ADDONNAME = ADDON.getAddonInfo('id')
67

7-
def log(message, level=xbmc.LOGNOTICE):
8+
def log(message, level=xbmc.LOGINFO):
89
xbmc.log('[%s] %s' % (ADDONNAME, message.encode('utf-8')), level)
910

1011
def getSetting(opt):
@@ -34,20 +35,36 @@ def validateAuthToken(authToken):
3435

3536
def updateSavedAddonVersion():
3637
setSetting('currAddonVersion', getAddonVersion())
37-
38+
3839
def intToCompString(comp):
3940
switch = {
40-
0: "COMP_GRABBER",
41-
1: "COMP_V4L",
42-
2: "COMP_LEDDEVICE",
43-
3: "COMP_SMOOTHING",
44-
4: "COMP_BLACKBORDER",
45-
5: "COMP_FORWARDER",
46-
6: "COMP_BOBLIGHTSERVER",
47-
7: "COMP_ALL",
41+
0: "GRABBER",
42+
1: "V4L",
43+
2: "LEDDEVICE",
44+
3: "SMOOTHING",
45+
4: "BLACKBORDER",
46+
5: "FORWARDER",
47+
6: "UDPLISTENER",
48+
7: "BOBLIGHTSERVER",
49+
8: "ALL",
4850
}
4951
return switch.get(comp, "NOT_FOUND")
5052

53+
def isPy3():
54+
return sys.version_info[0] == 3
55+
56+
def bytesDecodeUtf8(data):
57+
if isPy3():
58+
return data.decode('utf-8')
59+
else:
60+
return data
61+
62+
def bytesEncodeUtf8(data):
63+
if isPy3():
64+
return data.encode('utf-8')
65+
else:
66+
return data
67+
5168
def modeTo3D(mode=None):
5269
switch = {
5370
"split_vertical": "3DSBS",
@@ -57,7 +74,7 @@ def modeTo3D(mode=None):
5774

5875
def getStereoscopeMode():
5976
try:
60-
response = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669}'))
77+
response = json.loads(bytesDecodeUtf8(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669}')))
6178
mode = response["result"]["stereoscopicmode"]["mode"]
6279
return modeTo3D(mode)
6380

0 commit comments

Comments
 (0)