-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdate.py
More file actions
101 lines (87 loc) · 3.5 KB
/
update.py
File metadata and controls
101 lines (87 loc) · 3.5 KB
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
# -*- coding: utf-8 -*-
# * 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 2, 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; see the file LICENSE.txt. If not, write to
# * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# * http://www.gnu.org/copyleft/gpl.html
# *
#Modules General
import os
from xml.etree import ElementTree
import xbmc
import xbmcaddon
from resources.lib.ambibox import AmbiBox
__addon__ = xbmcaddon.Addon("script.ambibox")
__cwd__ = __addon__.getAddonInfo('path')
__resource__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib'))
__settings__ = xbmcaddon.Addon("script.ambibox")
__language__ = __settings__.getLocalizedString
__scriptname__ = __addon__.getAddonInfo('name')
__settingsdir__ = xbmc.translatePath(os.path.join(__cwd__, 'resources'))
mambibox = AmbiBox(__settings__.getSetting("host"), int(__settings__.getSetting("port")))
def info(msg):
xbmc.log("### [%s] - %s" % (__scriptname__, msg,), level=xbmc.LOGNOTICE)
def notification(text):
text = text.encode('utf-8')
info(text)
if __settings__.getSetting("notification") == 'true':
icon = __settings__.getAddonInfo("icon")
smallicon = icon.encode("utf-8")
xbmc.executebuiltin('Notification(AmbiBox,' + text + ',1000,' + smallicon + ')')
def updateprofilesettings():
global mambibox
pstrl = []
if mambibox.connect() == 0:
pfls = mambibox.getProfiles()
defpfl = "None"
pstrl.append('None')
pstrl.append('|')
for pfl in pfls:
pstrl.append(str(pfl))
pstrl.append('|')
if str(pfl).lower() == 'default':
defpfl = str(pfl)
del pstrl[-1]
pstr = "".join(pstrl)
doc = ElementTree.parse(__settingsdir__ + "\\settings.xml")
repl = ".//setting[@type='labelenum']"
fixg = doc.iterfind(repl)
for fixe in fixg:
fixe.set('values', pstr)
fixe.set('default', defpfl)
doc.write(__settingsdir__ + "\\settings.xml")
info('Settings refreshed from Ambibox Profiles')
notification(__language__(32036)) # @[Settings refreshed from Ambibox profiles]
else:
notification(__language__(32031)) # @[Failed to connect to AmbiBox]
def chkProfileSettings():
global mambibox
if mambibox.connect() == 0:
__settings = xbmcaddon.Addon("script.ambibox")
pfls = mambibox.getProfiles()
sets2chk = ['default_profile', 'audio_profile', 'video_profile']
vidfmts = ['2D', '3DS', '3DT']
ars = ['43', '32', '169', '185', '22', '24']
for vidfmt in vidfmts:
for ar in ars:
setn = vidfmt + '_' + ar
sets2chk.append(setn)
for setn in sets2chk:
pname = __settings.getSetting(setn)
if pname != 'None':
if not(pname in pfls):
__settings.setSetting(setn, 'None')
def main():
updateprofilesettings()
chkProfileSettings()
xbmc.executebuiltin('UpdateLocalAddons')
main()