From 6f00779d730966e90ea5e4c412b8d48e0781117e Mon Sep 17 00:00:00 2001 From: Abby Gourlay Date: Fri, 31 Jul 2020 23:51:26 +0100 Subject: [PATCH 1/2] Get resume from Kodi arguments --- jellyfin_kodi/entrypoint/default.py | 1 + jellyfin_kodi/entrypoint/service.py | 2 +- jellyfin_kodi/objects/actions.py | 21 ++++----------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index 2c2da3e4..93de8d28 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -70,6 +70,7 @@ class Events(object): elif mode == 'play': item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get() + item["resumePlayback"] = sys.argv[3].split(":")[1] == "true" Actions(server).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true') elif mode == 'playlist': diff --git a/jellyfin_kodi/entrypoint/service.py b/jellyfin_kodi/entrypoint/service.py index 55bc21e2..9fa890ed 100644 --- a/jellyfin_kodi/entrypoint/service.py +++ b/jellyfin_kodi/entrypoint/service.py @@ -414,7 +414,7 @@ class Service(xbmc.Monitor): properties = [ # TODO: review "jellyfin_state", "jellyfin_serverStatus", "jellyfin_currUser", - "jellyfin_play", "jellyfin_online", "jellyfin.connected", "jellyfin.resume", "jellyfin_startup", + "jellyfin_play", "jellyfin_online", "jellyfin.connected", "jellyfin_startup", "jellyfin.external", "jellyfin.external_check", "jellyfin_deviceId", "jellyfin_db_check", "jellyfin_pathverified", "jellyfin_sync" ] diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 57d28939..74cb76b0 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -86,8 +86,7 @@ class Actions(object): Detect the seektime for video type content. Verify the default video action set in Kodi for accurate resume behavior. ''' - seektime = window('jellyfin.resume.bool') - window('jellyfin.resume', clear=True) + seektime = None if item['MediaType'] in ('Video', 'Audio'): resume = item['UserData'].get('PlaybackPositionTicks') @@ -447,8 +446,8 @@ class Actions(object): listitem.setProperty('totaltime', str(obj['Runtime'])) listitem.setProperty('IsPlayable', 'true') listitem.setProperty('IsFolder', 'false') - - if obj['Resume'] and seektime is not False: + + if obj['Resume'] and item.get("resumePlayback"): listitem.setProperty('resumetime', str(obj['Resume'])) listitem.setProperty('StartPercent', str(((obj['Resume'] / obj['Runtime']) * 100) - 0.40)) else: @@ -807,19 +806,7 @@ def special_listener(): is_playing = player.isPlaying() count = int(window('jellyfin.external_count') or 0) - if (not is_playing and xbmc.getCondVisibility('Window.IsVisible(DialogContextMenu.xml)') and xbmc.getInfoLabel('Control.GetLabel(1002)') == xbmc.getLocalizedString(12021)): - - control = int(xbmcgui.Window(10106).getFocusId()) - - if control == 1002: # Start from beginning - - LOG.info("Resume dialog: Start from beginning selected.") - window('jellyfin.resume.bool', False) - else: - LOG.info("Resume dialog: Resume selected.") - window('jellyfin.resume.bool', True) - - elif is_playing and not window('jellyfin.external_check'): + if is_playing and not window('jellyfin.external_check'): time = player.getTime() if time > 1: # Not external player. From d8a7e43070238462786b6c7fe39b3b5785b7527e Mon Sep 17 00:00:00 2001 From: Abby Gourlay Date: Sat, 1 Aug 2020 00:14:31 +0100 Subject: [PATCH 2/2] Fixed playback time selection for forced transcodes --- jellyfin_kodi/objects/actions.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 74cb76b0..cc1019ae 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -86,23 +86,22 @@ class Actions(object): Detect the seektime for video type content. Verify the default video action set in Kodi for accurate resume behavior. ''' - seektime = None if item['MediaType'] in ('Video', 'Audio'): resume = item['UserData'].get('PlaybackPositionTicks') - if resume and transcode and not seektime: + if resume and transcode: choice = self.resume_dialog(api.API(item, self.server).adjust_resume((resume or 0) / 10000000.0)) if choice is None: raise Exception("User backed out of resume dialog.") - seektime = False if not choice else True + item["resumePlayback"] = False if not choice else True - if settings('enableCinema.bool') and not seektime: + if settings('enableCinema.bool') and not item["resumePlayback"]: self._set_intros(item) - self.set_listitem(item, listitem, db_id, seektime) + self.set_listitem(item, listitem, db_id, None) playutils.set_properties(item, item['PlaybackInfo']['Method'], self.server_id) self.stack.append([item['PlaybackInfo']['Path'], listitem]) @@ -446,12 +445,13 @@ class Actions(object): listitem.setProperty('totaltime', str(obj['Runtime'])) listitem.setProperty('IsPlayable', 'true') listitem.setProperty('IsFolder', 'false') - + if obj['Resume'] and item.get("resumePlayback"): listitem.setProperty('resumetime', str(obj['Resume'])) listitem.setProperty('StartPercent', str(((obj['Resume'] / obj['Runtime']) * 100) - 0.40)) else: listitem.setProperty('resumetime', '0') + listitem.setProperty('StartPercent', '0') for track in obj['Streams']['video']: listitem.addStreamInfo('video', {