forked from mazkolain-zz/spotimc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.py
90 lines (68 loc) · 2.73 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
'''
Copyright 2011 Mikel Azkolain
This file is part of Spotimc.
Spotimc 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.
Spotimc 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 Spotimc. If not, see <http://www.gnu.org/licenses/>.
'''
__addon_id__ = 'script.audio.spotimc'
#Gather addon information
import os.path, xbmcaddon, xbmcgui
addon_cfg = xbmcaddon.Addon(__addon_id__)
__addon_path__ = addon_cfg.getAddonInfo('path')
__addon_version__ = addon_cfg.getAddonInfo('version')
#Open the loading window
loadingwin = xbmcgui.WindowXML("loading-window.xml", __addon_path__, "DefaultSkin")
loadingwin.show()
#Add the dll search path
import envutils
dll_dir = os.path.join(__addon_path__, "resources/dlls")
envutils.set_library_path(dll_dir)
#Add the libraries
libs_dir = os.path.join(__addon_path__, "resources/libs")
sys.path.insert(0, libs_dir)
#Add the skinutils module
sys.path.insert(0, os.path.join(libs_dir, "XbmcSkinUtils.egg"))
#Load font & include stuff
from skinutils import reload_skin
from skinutils.fonts import FontManager
from skinutils.includes import IncludeManager
try:
#Set font & include manager vars
fm = None
im = None
#Install custom fonts
fm = FontManager()
skin_dir = os.path.join(__addon_path__, "resources/skins/DefaultSkin")
xml_path = os.path.join(skin_dir, "720p/font.xml")
font_dir = os.path.join(skin_dir, "fonts")
fm.install_file(xml_path, font_dir)
#Install custom includes
im = IncludeManager()
include_path = os.path.join(__addon_path__, "resources/skins/DefaultSkin/720p/includes.xml")
im.install_file(include_path)
reload_skin()
#Import spotify & friends
sys.path.insert(0, os.path.join(libs_dir, "CherryPy.egg"))
sys.path.insert(0, os.path.join(libs_dir, "PyspotifyCtypes.egg"))
sys.path.insert(0, os.path.join(libs_dir, "PyspotifyCtypesProxy.egg"))
#Load & start the actual gui, no init code beyond this point
from spotimcgui import main
main(__addon_path__)
from _spotify import unload_library
unload_library()
finally:
#Cleanup includes and fonts
if im is not None:
del im
if fm is not None:
del fm
#Close the background loading window
loadingwin.close()