forked from kodi-community-addons/script.skin.helper.service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.py
156 lines (125 loc) · 6.53 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import xbmc
import xbmcplugin
import xbmcgui
import shutil
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 == "SETFORCEDVIEW":
contenttype = params.get("CONTENTTYPE",None)
setForcedView(contenttype)
elif action == "TOGGLEKODISETTING":
kodisetting = params.get("SETTING")
toggleKodiSetting(kodisetting)
elif action == "ENABLEVIEWS":
enableViews()
elif action == "VIDEOSEARCH":
from resources.lib.SearchDialog import SearchDialog
searchDialog = SearchDialog("script-skin_helper_service-CustomSearch.xml", ADDON_PATH, "Default", "1080i")
searchDialog.doModal()
del searchDialog
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",None)
colorPicker.winProperty = params.get("WINPROPERTY",None)
colorPicker.shortcutProperty = params.get("SHORTCUTPROPERTY",None)
colorPicker.doModal()
propname = params.get("SHORTCUTPROPERTY",None)
if propname:
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 == "RESETPVRTHUMBS":
path = WINDOW.getProperty("pvrthumbspath").decode("utf-8")
WINDOW.setProperty("resetPvrArtCache","reset")
success = True
ret = xbmcgui.Dialog().yesno(heading=ADDON.getLocalizedString(32089), line1=ADDON.getLocalizedString(32090)+path)
if ret:
dirs, files = xbmcvfs.listdir(path)
for file in files:
success = xbmcvfs.delete(os.path.join(path,file.decode("utf-8")))
for dir in dirs:
dirs2, files2 = xbmcvfs.listdir(os.path.join(path,dir.decode("utf-8")))
for file in files2:
success = xbmcvfs.delete(os.path.join(path,dir.decode("utf-8"),file.decode("utf-8")))
success = xbmcvfs.rmdir(os.path.join(path,dir.decode("utf-8")))
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()
if (__name__ == "__main__"):
xbmc.executebuiltin( "Dialog.Close(busydialog)" )
Main()
logMsg('finished loading script entry')