forked from vially/googlemusic-xbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.py
60 lines (41 loc) · 1.9 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
import sys, utils, xbmc
if (__name__ == "__main__" ):
utils.log(" ARGV: " + repr(sys.argv))
params = utils.paramsToDict(sys.argv[2])
action = params.pop('action','')
if action == 'play_song':
import GoogleMusicPlaySong
GoogleMusicPlaySong.GoogleMusicPlaySong().play(params)
else:
reload(sys)
sys.setdefaultencoding("utf-8")
import GoogleMusicStorage
storage = GoogleMusicStorage.storage
import GoogleMusicLogin
login = GoogleMusicLogin.GoogleMusicLogin()
addon = utils.addon
# if version changed clear cache
if not addon.getSetting('version') or addon.getSetting('version') != addon.getAddonInfo('version'):
storage.clearCache()
login.clearCookie()
addon.setSetting('version', addon.getAddonInfo('version'))
# check for initing cookies, db and library
storage.checkDbInit()
login.checkCredentials()
login.checkCookie()
login.initDevice()
# check if library needs to be loaded
if addon.getSetting('fetched_all_songs') == '0':
xbmc.executebuiltin("XBMC.Notification(%s,%s,5000,%s)" % (utils.plugin, utils.tryEncode(addon.getLocalizedString(30105)) ,addon.getAddonInfo('icon')))
utils.log('Loading library')
import GoogleMusicApi
GoogleMusicApi.GoogleMusicApi().loadLibrary()
if addon.getSetting('auto_export')=='true' and addon.getSetting('export_path'):
import GoogleMusicActions
GoogleMusicActions.GoogleMusicActions().exportLibrary(addon.getSetting('export_path'))
if action:
import GoogleMusicActions
GoogleMusicActions.GoogleMusicActions().executeAction(action, params)
else:
import GoogleMusicNavigation
GoogleMusicNavigation.GoogleMusicNavigation().listMenu(params)