-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddon.py
96 lines (84 loc) · 3.14 KB
/
addon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017 Zomboided
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This module displays the Zomboided Tools menu options
import xbmc
import xbmcaddon
import xbmcplugin
import xbmcgui
import os
from libs.utility import debugTrace, errorTrace, infoTrace
from libs.logbox import popupKodiLog
from libs.speedtest import speedTest
from libs.managefiles import copyLog
from libs.common import getIconPath
debugTrace("-- Entered addon.py " + sys.argv[0] + " " + sys.argv[1] + " " + sys.argv[2] + " --")
# Set the addon name for use in the dialogs
addon = xbmcaddon.Addon()
addon_name = addon.getAddonInfo("name")
# Get the arguments passed in
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = sys.argv[2].split("?", )
action = ""
params = ""
# If an argument has been passed in, the first character will be a ?, so the first list element is empty
inc = 0
for token in args:
if inc == 1 : action = token
if inc > 1 : params = params + token
inc = inc + 1
debugTrace("Parsed arguments to action=" + action + " params=" + params)
def topLevel():
# Build the top level menu with URL callbacks to this plugin
debugTrace("Displaying the top level menu")
url = base_url + "?settings"
li = xbmcgui.ListItem("Add-on Settings")
li.setArt({"icon":getIconPath()+"box.png"})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
url = base_url + "?viewlog"
li = xbmcgui.ListItem("View Log")
li.setArt({"icon":getIconPath()+"box.png"})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
url = base_url + "?copylog"
li = xbmcgui.ListItem("Copy Log")
li.setArt({"icon":getIconPath()+"box.png"})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
url = base_url + "?speedtest"
li = xbmcgui.ListItem("LAN Speed Test")
li.setArt({"icon":getIconPath()+"box.png"})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)
return
def back():
xbmc.executebuiltin("Action(ParentDir)")
return
if action == "settings" :
debugTrace("Opening settings")
xbmc.executebuiltin("Addon.OpenSettings(service.zomboided.tools)")
elif action == "viewlog" :
debugTrace("Displaying log")
popupKodiLog()
elif action == "copylog" :
debugTrace("Copying log")
copyLog()
elif action == "speedtest" :
debugTrace("Displaying log")
speedTest()
else: topLevel()
debugTrace("-- Exit addon.py --")