From 77843c7f1d5d5a5ba0ab2d6c15dbed8e6c4c3a63 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 6 Sep 2018 17:28:51 -0500 Subject: [PATCH] Fix report progress And other issues --- resources/lib/downloader.py | 2 +- resources/lib/entrypoint/service.py | 4 ++-- resources/lib/helper/playutils.py | 3 ++- resources/lib/monitor.py | 2 +- resources/lib/player.py | 20 ++++++++++++++------ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/resources/lib/downloader.py b/resources/lib/downloader.py index 6d1e51f2..94a2c47f 100644 --- a/resources/lib/downloader.py +++ b/resources/lib/downloader.py @@ -301,7 +301,7 @@ def get_objects(src, filename): if not xbmcvfs.exists(temp): xbmcvfs.mkdir(temp) else: - delete_build(temp) + delete_build() path = os.path.join(temp, filename) try: diff --git a/resources/lib/entrypoint/service.py b/resources/lib/entrypoint/service.py index 46d2aa18..ce248481 100644 --- a/resources/lib/entrypoint/service.py +++ b/resources/lib/entrypoint/service.py @@ -98,9 +98,9 @@ class Service(xbmc.Monitor): if self.monitor.player.isPlaying(): difference = datetime.today() - self.settings['last_progress'] - if difference.seconds > 270: + if difference.seconds > 10: - event("ReportProgressRequested", None) + event('ReportProgressRequested', {'Report': difference.seconds > 270}) self.settings['last_progress'] = datetime.today() if self.waitForAbort(1): diff --git a/resources/lib/helper/playutils.py b/resources/lib/helper/playutils.py index 2e81d7a0..322739c7 100644 --- a/resources/lib/helper/playutils.py +++ b/resources/lib/helper/playutils.py @@ -45,7 +45,8 @@ def set_properties(item, method, server_id=None): 'DeviceId': client.get_device_id(), 'SubsMapping': info.get('Subtitles'), 'AudioStreamIndex': info.get('AudioStreamIndex'), - 'SubtitleStreamIndex': info.get('SubtitleStreamIndex') + 'SubtitleStreamIndex': info.get('SubtitleStreamIndex'), + 'CurrentPosition': info.get('CurrentPosition') }) window('emby_play.json', current) diff --git a/resources/lib/monitor.py b/resources/lib/monitor.py index 485fa33f..e1aabf2b 100644 --- a/resources/lib/monitor.py +++ b/resources/lib/monitor.py @@ -189,7 +189,7 @@ class Monitor(xbmc.Monitor): data.get('SubtitleStreamIndex')).start() elif method == 'ReportProgressRequested': - self.player.report_playback() + self.player.report_playback(data['Report']) elif method == 'Playstate': self.playstate(data) diff --git a/resources/lib/player.py b/resources/lib/player.py index b05b182d..d751769d 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -100,11 +100,13 @@ class Player(xbmc.Player): 'SubtitleStreamIndex': item['SubtitleStreamIndex'] } item['Server']['api'].session_playing(data) - self.set_audio_subs(item['AudioStreamIndex'], item['SubtitleStreamIndex']) - self.detect_audio_subs(item) - window('emby.skip.%s.bool' % item['Id'], True) + if monitor.waitForAbort(2): + return + + self.set_audio_subs(item['AudioStreamIndex'], item['SubtitleStreamIndex']) + def set_item(self, file, item): ''' Set playback information. @@ -131,7 +133,7 @@ class Player(xbmc.Player): item.update({ 'File': file, - 'CurrentPosition': int(seektime), + 'CurrentPosition': item.get('CurrentPosition') or int(seektime), 'Muted': muted, 'Volume': volume, 'Server': Emby(item['ServerId']), @@ -244,7 +246,7 @@ class Player(xbmc.Player): self.report_playback() LOG.debug("--[ seek ]") - def report_playback(self): + def report_playback(self, report=True): ''' Report playback progress to emby server. ''' @@ -254,6 +256,12 @@ class Player(xbmc.Player): return item = self.played[current_file] + + if not report: + item['CurrentPosition'] = int(self.getTime()) + + return + result = JSONRPC('Application.GetProperties').execute({'properties': ["volume", "muted"]}) result = result.get('result', {}) item['Volume'] = result.get('volume') @@ -309,7 +317,7 @@ class Player(xbmc.Player): if item['CurrentPosition'] and item['Runtime']: try: - if window('emby.external'): + if window('emby.external.bool'): window('emby.external', clear=True) raise ValueError