本文整理匯總了Python中scrobbler.Scrobbler.playbackPaused方法的典型用法代碼示例。如果您正苦於以下問題:Python Scrobbler.playbackPaused方法的具體用法?Python Scrobbler.playbackPaused怎麽用?Python Scrobbler.playbackPaused使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scrobbler.Scrobbler
的用法示例。
在下文中一共展示了Scrobbler.playbackPaused方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from scrobbler import Scrobbler [as 別名]
# 或者: from scrobbler.Scrobbler import playbackPaused [as 別名]
def run(self):
#while xbmc is running
scrobbler = Scrobbler()
scrobbler.start()
while (not (self.abortRequested or xbmc.abortRequested)):
time.sleep(1)
try:
tn = telnetlib.Telnet('localhost', 9090, 10)
except IOError as (errno, strerror):
#connection failed, try again soon
Debug("[Notification Service] Telnet too soon? ("+str(errno)+") "+strerror)
time.sleep(1)
continue
Debug("[Notification Service] Waiting~");
bCount = 0
while (not (self.abortRequested or xbmc.abortRequested)):
try:
if bCount == 0:
notification = ""
inString = False
[index, match, raw] = tn.expect(["(\\\\)|(\\\")|[{\"}]"], 0.2) #note, pre-compiled regex might be faster here
notification += raw
if index == -1: # Timeout
continue
if index == 0: # Found escaped quote
match = match.group(0)
if match == "\"":
inString = not inString
continue
if match == "{":
bCount += 1
if match == "}":
bCount -= 1
if bCount > 0:
continue
if bCount < 0:
bCount = 0
except EOFError:
break #go out to the other loop to restart the connection
Debug("[Notification Service] message: " + str(notification))
# Parse recieved notification
data = json.loads(notification)
# Forward notification to functions
if 'method' in data and 'params' in data and 'sender' in data['params'] and data['params']['sender'] == 'xbmc':
if data['method'] == 'Player.OnStop':
scrobbler.playbackEnded()
elif data['method'] == 'Player.OnPlay':
if 'data' in data['params'] and 'item' in data['params']['data'] and 'type' in data['params']['data']['item']:
scrobbler.playbackStarted(data['params']['data'])
elif data['method'] == 'Player.OnPause':
scrobbler.playbackPaused()
elif data['method'] == 'System.OnQuit':
self.abortRequested = True
示例2: run
# 需要導入模塊: from scrobbler import Scrobbler [as 別名]
# 或者: from scrobbler.Scrobbler import playbackPaused [as 別名]
def run(self):
#while xbmc is running
scrobbler = Scrobbler()
scrobbler.start()
while (not (self.abortRequested or xbmc.abortRequested)):
time.sleep(1)
try:
tn = telnetlib.Telnet('localhost', 9090, 10)
except IOError as (errno, strerror):
#connection failed, try again soon
Debug("[Notification Service] Telnet too soon? ("+str(errno)+") "+strerror)
time.sleep(1)
continue
Debug("[Notification Service] Waiting~");
bCount = 0
while (not (self.abortRequested or xbmc.abortRequested)):
try:
if bCount == 0:
notification = ""
inString = False
[index, match, raw] = tn.expect(["(\\\\)|(\\\")|[{\"}]"], 0.2) #note, pre-compiled regex might be faster here
notification += raw
if index == -1: # Timeout
continue
if index == 0: # Found escaped quote
match = match.group(0)
if match == "\"":
inString = not inString
continue
if match == "{":
bCount += 1
if match == "}":
bCount -= 1
if bCount > 0:
continue
if bCount < 0:
bCount = 0
except EOFError:
break #go out to the other loop to restart the connection
Debug("[Notification Service] message: " + str(notification))
# Parse recieved notification
data = json.loads(notification)
# Forward notification to functions
if 'method' in data and 'params' in data and 'sender' in data['params'] and data['params']['sender'] == 'xbmc':
if data['method'] == 'Player.OnStop':
Debug("pb ended, %s" % getSync_after_x())
scrobbler.playbackEnded(data=data) # this is using syncIncreasePlayCount already
elif data['method'] == 'Player.OnPlay':
if 'data' in data['params'] and 'item' in data['params']['data'] and 'id' in data['params']['data']['item'] and 'type' in data['params']['data']['item']:
#fixme: look here for current position?
scrobbler.playbackStarted(data['params']['data'])
elif data['method'] == 'Player.OnPause':
scrobbler.playbackPaused()
elif data['method'] == 'VideoLibrary.OnUpdate':
Debug("OnUpdate %s" % data)
if 'data' in data['params'] and 'playcount' in data['params']['data']:
noBugging = getNoBugging()
# 'playcount' in data indicates that playcount has changed. so we received a seen status on the item
if getSync_after_x() and data['params']['data']["playcount"] >= 1:
# we've played a file and consider it seen
syncIncreasePlayCount()
Debug("syncing, playcount: %s" % data['params']['data']["playcount"])
syncAfterX(daemon=noBugging)
onlyOnUnwatchMark = getInstantOnlyOnUnwatchMark()
Debug("instantUpdateOnWatchMark: %s, %s" % (getInstantUpdateOnWatchMark(), onlyOnUnwatchMark))
if (getInstantUpdateOnWatchMark() and not onlyOnUnwatchMark) or (data['params']['data']["playcount"] == 0 and onlyOnUnwatchMark):
instantSyncPlayCount(data)
elif data['method'] == 'System.OnQuit':
self.abortRequested = True