本文整理匯總了Python中scrobbler.Scrobbler.join方法的典型用法代碼示例。如果您正苦於以下問題:Python Scrobbler.join方法的具體用法?Python Scrobbler.join怎麽用?Python Scrobbler.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scrobbler.Scrobbler
的用法示例。
在下文中一共展示了Scrobbler.join方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from scrobbler import Scrobbler [as 別名]
# 或者: from scrobbler.Scrobbler import join [as 別名]
class NotificationService:
_scrobbler = None
def __init__(self):
self.run()
def _dispatch(self, data):
Debug("[Notification] Dispatch: %s" % data)
xbmc.sleep(500)
action = data["action"]
if action == "started":
p = {"item": {"type": data["type"], "id": data["id"]}}
self._scrobbler.playbackStarted(p)
elif action == "ended" or action == "stopped":
self._scrobbler.playbackEnded()
elif action == "paused":
self._scrobbler.playbackPaused()
elif action == "resumed":
self._scrobbler.playbackResumed()
elif action == "databaseUpdated":
if do_sync('movies'):
movies = SyncMovies(show_progress=False)
movies.Run()
if do_sync('episodes'):
episodes = SyncEpisodes(show_progress=False)
episodes.Run()
elif action == "scanStarted":
Debug("[Notification] Dispatch: scanStarted")
else:
Debug("[Notification] '%s' unknown dispatch action!" % action)
def run(self):
Debug("[Notification] Starting")
# setup event driven classes
self.Player = traktPlayer(action = self._dispatch)
self.Monitor = traktMonitor(action = self._dispatch)
# initalize scrobbler class
self._scrobbler = Scrobbler()
self._scrobbler.start()
# start loop for events
while (not xbmc.abortRequested):
xbmc.sleep(500)
# we aborted
if xbmc.abortRequested:
Debug("[Notification] abortRequested received, shutting down.")
# join scrobbler, to wait for termination
Debug("[Notification] Joining scrobbler thread to wait for exit.")
self._scrobbler.join()
示例2: __init__
# 需要導入模塊: from scrobbler import Scrobbler [as 別名]
# 或者: from scrobbler.Scrobbler import join [as 別名]
class NotificationService:
_scrobbler = None
def __init__(self):
self.run()
def _dispatch(self, data):
Debug("[Notification] Dispatch: %s" % data)
xbmc.sleep(500)
# check if scrobbler thread is still alive
if not self._scrobbler.isAlive():
if self.Player._playing and not self._scrobbler.pinging:
# make sure pinging is set
self._scrobbler.pinging = True
Debug("[Notification] Scrobler thread died, restarting.")
self._scrobbler.start()
action = data["action"]
if action == "started":
del data["action"]
p = {"item": data}
self._scrobbler.playbackStarted(p)
elif action == "ended" or action == "stopped":
self._scrobbler.playbackEnded()
elif action == "paused":
self._scrobbler.playbackPaused()
elif action == "resumed":
self._scrobbler.playbackResumed()
elif action == "seek" or action == "seekchapter":
self._scrobbler.playbackSeek()
elif action == "databaseUpdated":
if do_sync('movies'):
movies = SyncMovies(show_progress=False, api=globals.traktapi)
movies.Run()
if do_sync('episodes'):
episodes = SyncEpisodes(show_progress=False, api=globals.traktapi)
episodes.Run()
elif action == "scanStarted":
pass
elif action == "settingsChanged":
Debug("[Notification] Settings changed, reloading.")
globals.traktapi.updateSettings()
else:
Debug("[Notification] '%s' unknown dispatch action!" % action)
def run(self):
Debug("[Notification] Starting")
# setup event driven classes
self.Player = traktPlayer(action = self._dispatch)
self.Monitor = traktMonitor(action = self._dispatch)
# init traktapi class
globals.traktapi = traktAPI()
# initalize scrobbler class
self._scrobbler = Scrobbler(globals.traktapi)
# start loop for events
while (not xbmc.abortRequested):
xbmc.sleep(500)
# we aborted
if xbmc.abortRequested:
Debug("[Notification] abortRequested received, shutting down.")
# delete player/monitor
del self.Player
del self.Monitor
# join scrobbler, to wait for termination
Debug("[Notification] Joining scrobbler thread to wait for exit.")
self._scrobbler.join()