def __init__(self):
self.addon = xbmcaddon.Addon(id=ADDON_ID)
self.kodimonitor = xbmc.Monitor()
self.spotty = Spotty()
# spotipy and the webservice are always prestarted in the background
# the auth key for spotipy will be set afterwards
# the webserver is also used for the authentication callbacks from spotify api
self.sp = spotipy.Spotify()
self.connect_player = ConnectPlayer(sp=self.sp, spotty=self.spotty)
self.proxy_runner = ProxyRunner(self.spotty)
self.proxy_runner.start()
webport = self.proxy_runner.get_port()
log_msg('started webproxy at port {0}'.format(webport))
# authenticate
self.token_info = self.get_auth_token()
if self.token_info and not self.kodimonitor.abortRequested():
# initialize spotipy
self.sp._auth = self.token_info["access_token"]
me = self.sp.me()
log_msg("Logged in to Spotify - Username: %s" % me["id"], xbmc.LOGNOTICE)
# start experimental spotify connect daemon
if self.addon.getSetting("connect_player") == "true" and self.spotty.playback_supported:
self.connect_player.start()
# start mainloop
self.main_loop()
评论列表
文章目录