Small fixes

This commit is contained in:
tomkat83 2016-01-12 15:53:06 +01:00
parent b2a9f1a453
commit 9103f0516f
3 changed files with 23 additions and 22 deletions

View file

@ -331,6 +331,8 @@ class DownloadUtils():
if r.text == '' and r.status_code == 200:
self.logMsg("====== 200 Success ======", 2)
self.logMsg("Answer from PMS does not contain a body", 2)
self.logMsg("Unable to convert the response for: %s" % url, 2)
self.logMsg("Content-type was: %s" % r.headers['content-type'], 2)
except:
self.logMsg("Unable to convert the response for: %s" % url, 2)
self.logMsg("Content-type was: %s" % r.headers['content-type'], 2)

View file

@ -34,10 +34,9 @@ def doPlayback(itemid, dbid):
# Get a first XML to get the librarySectionUUID
item = PlexAPI.PlexAPI().GetPlexMetadata(itemid)
# Use that to call the playlist
playlist = PlexAPI.API(item).GetPlexPlaylist()
if playlist:
pbutils.PlaybackUtils(playlist).play(itemid, dbid)
xmlPlaylist = PlexAPI.API(item).GetPlexPlaylist()
if xmlPlaylist:
pbutils.PlaybackUtils(xmlPlaylist).play(itemid, dbid)
else:
# No playlist received e.g. when directly playing trailers
pbutils.PlaybackUtils(item).play(itemid, dbid)
@ -48,7 +47,7 @@ def resetAuth():
resp = xbmcgui.Dialog().yesno(
heading="Warning",
line1=(
"Emby might lock your account if you fail to log in too many times. "
"Plex might lock your account if you fail to log in too many times. "
"Proceed anyway?"))
if resp == 1:
utils.logMsg("EMBY", "Reset login attempts.", 1)

View file

@ -298,7 +298,7 @@ class Player(xbmc.Player):
# }
if paused == 'stopped':
state = 'stopped'
elif paused == 'True':
elif paused is True:
state = 'paused'
else:
state = 'playing'
@ -458,7 +458,7 @@ class Player(xbmc.Player):
if currentPosition and runtime:
try:
percentComplete = (currentPosition * 10000000) / int(runtime)
percentComplete = (currentPosition * 10000) / int(runtime)
except ZeroDivisionError:
# Runtime is 0.
percentComplete = 0
@ -505,20 +505,20 @@ class Player(xbmc.Player):
doUtils.downloadUrl(url, type="DELETE")
self.played_info.clear()
def stopPlayback(self, data):
self.logMsg("stopPlayback called", 2)
itemId = data['item_id']
currentPosition = data['currentPosition']
positionTicks = int(currentPosition * 10000000)
url = "{server}/emby/Sessions/Playing/Stopped"
postdata = {
'ItemId': itemId,
'MediaSourceId': itemId,
'PositionTicks': positionTicks
def stopPlayback(self, data):
self.logMsg("stopPlayback called", 2)
itemId = data['item_id']
playTime = data['currentPosition']
duration = data.get('runtime', '')
url = "{server}/:/timeline?"
args = {
'ratingKey': itemId,
'state': 'stopped', # 'stopped', 'paused', 'buffering', 'playing'
'time': int(playTime) * 1000,
'duration': int(duration) * 1000
}
self.doUtils.downloadUrl(url, postBody=postdata, type="POST")
url = url + urlencode(args)
self.doUtils.downloadUrl(url, type="GET")