diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 938a6c37..b8ddc3a4 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -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) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index aff64718..a807954e 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -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) diff --git a/resources/lib/player.py b/resources/lib/player.py index a9a5ef7e..1003957e 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -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") \ No newline at end of file + url = url + urlencode(args) + self.doUtils.downloadUrl(url, type="GET")