forked from kodi-community-addons/script.skin.helper.service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.py
231 lines (193 loc) · 10.4 KB
/
default.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/usr/bin/python
# -*- coding: utf-8 -*-
#from resources.lib.Utils import *
from resources.lib.MainModule import *
class Main:
def getParams(self):
#extract the params from the called script path
params = {}
for arg in sys.argv:
if arg == 'script.skin.helper.service' or arg == 'default.py':
continue
arg = arg.replace('"', '').replace("'", " ").replace("?", "")
if "=" in arg:
paramname = arg.split('=')[0].upper()
paramvalue = arg.split('=')[1]
params[paramname] = paramvalue
logMsg("Parameter string: " + str(params))
return params
def __init__(self):
logMsg('started loading script entry')
params = self.getParams()
if params:
action = params.get("ACTION","").upper()
if action =="ADDSHORTCUT":
addShortcutWorkAround()
elif action == "MUSICSEARCH":
musicSearch()
elif action == "SETVIEW":
setView()
elif action == "SEARCHYOUTUBE":
title = params.get("TITLE",None)
windowHeader = params.get("HEADER","")
searchYouTube(title,windowHeader)
elif action == "SETFOCUS":
control = params.get("CONTROL",None)
xbmc.sleep(50)
xbmc.executebuiltin("Control.SetFocus(%s)"%control)
elif action == "SETFORCEDVIEW":
contenttype = params.get("CONTENTTYPE",None)
setForcedView(contenttype)
elif action == "SETSKINSETTING":
setting = params.get("SETTING","")
windowHeader = params.get("HEADER","")
setSkinSetting(setting,windowHeader)
elif action == "SETSKINSHORTCUTSPROPERTY":
setting = params.get("SETTING","")
windowHeader = params.get("HEADER","")
property = params.get("PROPERTY","")
setSkinShortCutsProperty(setting,windowHeader,property)
elif action == "TOGGLEKODISETTING":
kodisetting = params.get("SETTING")
toggleKodiSetting(kodisetting)
elif action == "ENABLEVIEWS":
enableViews()
elif action == "SPLASHSCREEN":
file = params.get("FILE","")
duration = params.get("DURATION","")
if duration:
show_splash(file,int(duration))
else:
show_splash(file)
elif action == "VIDEOSEARCH":
from resources.lib.SearchDialog import SearchDialog
searchDialog = SearchDialog("script-skin_helper_service-CustomSearch.xml", ADDON_PATH, "Default", "1080i")
searchDialog.doModal()
resultAction = searchDialog.action
del searchDialog
if resultAction:
if "jsonrpc" in resultAction:
xbmc.executeJSONRPC(resultAction)
else:
xbmc.executebuiltin(resultAction)
elif action == "SHOWINFO":
xbmc.executebuiltin( "ActivateWindow(busydialog)" )
from resources.lib.InfoDialog import GUI
item = None
if params.get("MOVIEID"):
item = getJSON('VideoLibrary.GetMovieDetails', '{ "movieid": %s, "properties": [ %s ] }' %(params.get("MOVIEID"),fields_movies))
content = "movies"
elif params.get("EPISODEID"):
item = getJSON('VideoLibrary.GetEpisodeDetails', '{ "episodeid": %s, "properties": [ %s ] }' %(params.get("EPISODEID"),fields_episodes))
content = "episodes"
elif params.get("TVSHOWID"):
item = getJSON('VideoLibrary.GetTVShowDetails', '{ "tvshowid": %s, "properties": [ %s ] }' %(params.get("TVSHOWID"),fields_tvshows))
content = "tvshows"
if item:
if item.get("streamdetails"): item["streamdetails2"] = item["streamdetails"]
liz = createListItem(item)
liz.setProperty("path", item.get("file"))
liz.setProperty("json",repr(item))
info_dialog = GUI( "script-skin_helper_service-CustomInfo.xml" , ADDON_PATH, "Default", "1080i", listitem=liz, content=content )
info_dialog.doModal()
resultAction = info_dialog.action
del info_dialog
if resultAction:
if "jsonrpc" in resultAction:
xbmc.executeJSONRPC(resultAction)
else:
xbmc.executebuiltin(resultAction)
xbmc.executebuiltin( "Dialog.Close(busydialog)" )
elif action == "COLORPICKER":
from resources.lib.ColorPicker import ColorPicker
colorPicker = ColorPicker("script-skin_helper_service-ColorPicker.xml", ADDON_PATH, "Default", "1080i")
colorPicker.skinString = params.get("SKINSTRING","")
colorPicker.winProperty = params.get("WINPROPERTY","")
colorPicker.activePalette = params.get("PALETTE","")
colorPicker.headerLabel = params.get("HEADER","")
propname = params.get("SHORTCUTPROPERTY","")
colorPicker.shortcutProperty = propname
colorPicker.doModal()
if propname and not isinstance(colorPicker.result, int):
wid = xbmcgui.getCurrentWindowDialogId()
currentWindow = xbmcgui.Window( xbmcgui.getCurrentWindowDialogId() )
currentWindow.setProperty("customProperty",propname)
currentWindow.setProperty("customValue",colorPicker.result[0])
xbmc.executebuiltin("SendClick(404)")
xbmc.sleep(250)
currentWindow.setProperty("customProperty",propname+".name")
currentWindow.setProperty("customValue",colorPicker.result[1])
xbmc.executebuiltin("SendClick(404)")
del colorPicker
elif action == "COLORTHEMES":
from resources.lib.ColorThemes import ColorThemes
colorThemes = ColorThemes("DialogSelect.xml", ADDON_PATH)
colorThemes.daynight = params.get("DAYNIGHT",None)
colorThemes.doModal()
del colorThemes
elif action == "CONDITIONALBACKGROUNDS":
from resources.lib.ConditionalBackgrounds import ConditionalBackgrounds
conditionalBackgrounds = ConditionalBackgrounds("DialogSelect.xml", ADDON_PATH)
conditionalBackgrounds.doModal()
del conditionalBackgrounds
elif action == "CREATECOLORTHEME":
import resources.lib.ColorThemes as colorThemes
colorThemes.createColorTheme()
elif action == "RESTORECOLORTHEME":
import resources.lib.ColorThemes as colorThemes
colorThemes.restoreColorTheme()
elif action == "OVERLAYTEXTURE":
selectOverlayTexture()
elif action == "BUSYTEXTURE":
selectBusyTexture()
elif action == "RESETCACHE":
path = params.get("PATH")
if path == "pvr":
path = WINDOW.getProperty("SkinHelper.pvrthumbspath").decode("utf-8")
WINDOW.setProperty("resetPvrArtCache","reset")
elif path == "music":
path = "special://profile/addon_data/script.skin.helper.service/musicart/"
WINDOW.setProperty("resetMusicArtCache","reset")
elif path == "wallbackgrounds":
path = "special://profile/addon_data/script.skin.helper.service/wallbackgrounds/"
WINDOW.setProperty("resetWallArtCache","reset")
else: path = None
if path:
success = True
ret = xbmcgui.Dialog().yesno(heading=ADDON.getLocalizedString(32089), line1=ADDON.getLocalizedString(32090)+path)
if ret:
success = recursiveDelete(path)
if success:
xbmcgui.Dialog().ok(heading=ADDON.getLocalizedString(32089), line1=ADDON.getLocalizedString(32091))
else:
xbmcgui.Dialog().ok(heading=ADDON.getLocalizedString(32089), line1=ADDON.getLocalizedString(32092))
elif action == "BACKUP":
import resources.lib.BackupRestore as backup
filter = params.get("FILTER","")
silent = params.get("SILENT",None)
promptfilename = params.get("PROMPTFILENAME","false")
backup.backup(filter,silent,promptfilename.lower())
elif action == "RESTORE":
import resources.lib.BackupRestore as backup
silent = params.get("SILENT",None)
backup.restore(silent)
elif action == "RESET":
import resources.lib.BackupRestore as backup
backup.reset()
xbmc.sleep(2000)
setSkinVersion()
elif action == "DIALOGOK":
headerMsg = params.get("HEADER")
bodyMsg = params.get("MESSAGE")
xbmcgui.Dialog().ok(heading=headerMsg, line1=bodyMsg)
elif action == "STRIPSTRING":
splitchar = params.get("SPLITCHAR")
string = params.get("STRING")
output = params.get("OUTPUT")
string = string.split(splitchar)[0]
WINDOW.setProperty(output, string)
if (__name__ == "__main__"):
xbmc.executebuiltin( "Dialog.Close(busydialog)" )
if not WINDOW.getProperty("SkinHelper.KodiExit"):
Main()
logMsg('finished loading script entry')