Skip to content

Commit 6d2717d

Browse files
committed
Add compatibility for kodi 19 and bump version
1 parent 1ade03d commit 6d2717d

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

addon.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="plugin.video.flix" name="Flix" provider-name="i96751414" version="0.0.10">
2+
<addon id="plugin.video.flix" name="Flix" provider-name="i96751414" version="0.0.11">
33
<requires>
4-
<import addon="xbmc.python" version="2.24.0"/>
4+
<!--<import addon="xbmc.python" version="3.0.0"/>-->
55
<import addon="script.module.routing" version="0.2.3"/>
66
<import addon="script.module.requests" version="2.22.0"/>
77
<import addon="script.module.cached" version="0.0.1"/>
88
<import addon="script.module.tmdbsimple" version="2.2.0"/>
9-
<import addon="script.module.futures" version="2.2.0"/>
109
<import addon="script.module.defusedxml" version="0.6.0"/>
10+
<!-- futures must be optional so we have py2/3 compatibility -->
11+
<import addon="script.module.futures" version="2.2.0" optional="true"/>
1112
</requires>
1213
<extension point="xbmc.python.pluginsource" library="navigation.py">
1314
<provides>video</provides>

dependencies.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from lib.api.compatibility import register_module
2+
3+
register_module("concurrent.futures", "script.module.futures")

lib/api/compatibility.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import importlib
2+
import os
3+
import sys
4+
5+
import xbmc
6+
import xbmcaddon
7+
from defusedxml import ElementTree
8+
9+
PY3 = sys.version_info.major >= 3
10+
11+
12+
class UndefinedModuleError(ImportError):
13+
pass
14+
15+
16+
def register_module(name, py2_module=None, py3_module=None):
17+
try:
18+
importlib.import_module(name)
19+
xbmc.log("{} module is already installed".format(name), xbmc.LOGDEBUG)
20+
except ImportError:
21+
xbmc.log("Failed to import module. Going to register it.", xbmc.LOGDEBUG)
22+
module = py3_module if PY3 else py2_module
23+
if module is None:
24+
raise UndefinedModuleError("No module was defined")
25+
install_and_register_module(name, module)
26+
27+
28+
def install_and_register_module(name, module):
29+
xbmc.log("Installing and registering module {}:{}".format(name, module), xbmc.LOGINFO)
30+
xbmc.executebuiltin("InstallAddon(" + module + ")", wait=True)
31+
path = xbmcaddon.Addon(module).getAddonInfo("path")
32+
if not PY3:
33+
# noinspection PyUnresolvedReferences
34+
path = path.decode("utf-8")
35+
tree = ElementTree.parse(os.path.join(path, "addon.xml"))
36+
library_path = tree.find("./extension[@point='xbmc.python.module']").attrib["library"]
37+
sys.path.append(os.path.join(path, library_path))

navigation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
import dependencies # noqa
34
from lib.api.flix.kodi import ADDON_DATA
45
from lib.navigation import run
56

service.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dependencies # noqa
12
from lib.service import run
23

34
run()

0 commit comments

Comments
 (0)