From 64ac1f53493eda1e1c6ec7ac23bc0c9afd420703 Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 1 Mar 2021 10:39:17 +0100 Subject: [PATCH 1/7] Fix TypeError: function missing required argument 'message' --- resources/lib/context_entry.py | 4 ++-- resources/lib/initialsetup.py | 4 ++-- resources/lib/utils.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/lib/context_entry.py b/resources/lib/context_entry.py index 9f7970fc..8195016b 100644 --- a/resources/lib/context_entry.py +++ b/resources/lib/context_entry.py @@ -125,13 +125,13 @@ class ContextMenu(object): """ delete = True if utils.settings('skipContextMenu') != "true": - if not utils.dialog("yesno", heading="{plex}", text=utils.lang(33041)): + if not utils.dialog("yesno", heading="{plex}", message=utils.lang(33041)): LOG.info("User skipped deletion for: %s", self.plex_id) delete = False if delete: LOG.info("Deleting Plex item with id %s", self.plex_id) if PF.delete_item_from_pms(self.plex_id) is False: - utils.dialog("ok", heading="{plex}", text=utils.lang(30414)) + utils.dialog("ok", heading="{plex}", message=utils.lang(30414)) def _PMS_play(self): """ diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 52a0816e..af04de73 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -668,10 +668,10 @@ class InitialSetup(object): # If you use several Plex libraries of one kind, e.g. "Kids Movies" and # "Parents Movies", be sure to check https://goo.gl/JFtQV9 - # dialog.ok(heading=utils.lang(29999), text=utils.lang(39076)) + # dialog.ok(heading=utils.lang(29999), message=utils.lang(39076)) # Need to tell about our image source for collections: themoviedb.org - # dialog.ok(heading=utils.lang(29999), text=utils.lang(39717)) + # dialog.ok(heading=utils.lang(29999), message=utils.lang(39717)) # Make sure that we only ask these questions upon first installation utils.settings('InstallQuestionsAnswered', value='true') diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 97b4393f..a3c46ecd 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -155,8 +155,7 @@ def dialog(typus, *args, **kwargs): 'yesno', 'ok', 'notification', 'input', 'select', 'numeric' kwargs: heading='{plex}' title bar (here PlexKodiConnect) - message=lang(30128), Dialog content. Don't use with 'OK', 'yesno' - text=str(), Dialog content for 'OK'. 'yesno' + message=lang(30128), Dialog content time=5000, sound=True, nolabel=str(), For 'yesno' dialogs From dd69928b208154fec24144ebfc32606870d5ca5f Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 1 Mar 2021 10:48:12 +0100 Subject: [PATCH 2/7] Improve logging for websocket JSON loads --- resources/lib/websocket_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index fc32e0bd..62002db5 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -174,9 +174,9 @@ class PMS_Websocket(WebSocket): try: message = loads(message) - except ValueError: - LOG.error('%s: Error decoding message from websocket', - self.__class__.__name__) + except ValueError as err: + LOG.error('%s: Error decoding message from websocket: %s', + self.__class__.__name__, err) LOG.error(message) return try: From 2dc2b0d99bf7704ee6ad77d74219dd2de2c7839e Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 7 Mar 2021 15:16:23 +0100 Subject: [PATCH 3/7] Sync recently watched items individually before synching every playstate --- resources/lib/library_sync/full_sync.py | 61 +++++++++++++++++++------ 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 7c4644e1..29e406f9 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -136,7 +136,7 @@ class FullSync(common.LibrarySyncMixin, bg.KillableThread): LOG.error('Could not entirely process section %s', section) self.successful = False - def threaded_get_generators(self, kinds, section_queue, all_items): + def threaded_get_generators(self, kinds, section_queue, items): """ Getting iterators is costly, so let's do it in a dedicated thread """ @@ -153,17 +153,28 @@ class FullSync(common.LibrarySyncMixin, bg.KillableThread): continue section = sections.get_sync_section(section, plex_type=kind[0]) - if self.repair or all_items: + timestamp = section.last_sync - UPDATED_AT_SAFETY \ + if section.last_sync else None + if items == 'all': updated_at = None - else: - updated_at = section.last_sync - UPDATED_AT_SAFETY \ - if section.last_sync else None + last_viewed_at = None + elif items == 'watched': + if not timestamp: + # No need to sync playstate updates since section + # has not yet been synched + continue + else: + updated_at = None + last_viewed_at = timestamp + elif items == 'updated': + updated_at = timestamp + last_viewed_at = None try: section.iterator = PF.get_section_iterator( section.section_id, plex_type=section.plex_type, updated_at=updated_at, - last_viewed_at=None) + last_viewed_at=last_viewed_at) except RuntimeError: LOG.error('Sync at least partially unsuccessful!') LOG.error('Error getting section iterator %s', section) @@ -194,19 +205,42 @@ class FullSync(common.LibrarySyncMixin, bg.KillableThread): (v.PLEX_TYPE_ARTIST, v.PLEX_TYPE_ARTIST), (v.PLEX_TYPE_ALBUM, v.PLEX_TYPE_ARTIST), ]) + # ADD NEW ITEMS # We need to enforce syncing e.g. show before season before episode bg.FunctionAsTask(self.threaded_get_generators, None, - kinds, section_queue, False).start() + kinds, + section_queue, + items='all' if self.repair else 'updated').start() # Do the heavy lifting self.process_new_and_changed_items(section_queue, processing_queue) common.update_kodi_library(video=True, music=True) if self.should_cancel() or not self.successful: return + # In order to not delete all your songs again for playstate synch + if app.SYNC.enable_music: + kinds.extend([ + (v.PLEX_TYPE_SONG, v.PLEX_TYPE_ARTIST), + ]) + + # Update playstate progress since last sync - especially useful for + # users of very large libraries since this step is very fast + # These playstates will be synched twice + LOG.debug('Start synching playstate for last watched items') + bg.FunctionAsTask(self.threaded_get_generators, + None, + kinds, + section_queue, + items='watched').start() + self.processing_loop_playstates(section_queue) + if self.should_cancel() or not self.successful: + return + # Sync Plex playlists to Kodi and vice-versa if common.PLAYLIST_SYNC_ENABLED: + LOG.debug('Start playlist sync') if self.show_dialog: if self.dialog: self.dialog.close() @@ -217,14 +251,9 @@ class FullSync(common.LibrarySyncMixin, bg.KillableThread): return # SYNC PLAYSTATE of ALL items (otherwise we won't pick up on items that - # were set to unwatched). Also mark all items on the PMS to be able - # to delete the ones still in Kodi + # were set to unwatched or changed user ratings). Also mark all items on + # the PMS to be able to delete the ones still in Kodi LOG.debug('Start synching playstate and userdata for every item') - if app.SYNC.enable_music: - # In order to not delete all your songs again - kinds.extend([ - (v.PLEX_TYPE_SONG, v.PLEX_TYPE_ARTIST), - ]) # Make sure we're not showing an item's title in the sync dialog if not self.show_dialog_userdata and self.dialog: # Close the progress indicator dialog @@ -232,7 +261,9 @@ class FullSync(common.LibrarySyncMixin, bg.KillableThread): self.dialog = None bg.FunctionAsTask(self.threaded_get_generators, None, - kinds, section_queue, True).start() + kinds, + section_queue, + items='all').start() self.processing_loop_playstates(section_queue) if self.should_cancel() or not self.successful: return From 22d481a806ec5e22375550732718c0a559f45c29 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 7 Mar 2021 17:11:01 +0100 Subject: [PATCH 4/7] Fix PlexKodiConnect Kodi add-on icon and fanart not showing --- addon.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addon.xml b/addon.xml index dc47e6a3..7c8a764d 100644 --- a/addon.xml +++ b/addon.xml @@ -21,6 +21,10 @@ + + icon.png + fanart.jpg + Native Integration of Plex into Kodi Connect Kodi to your Plex Media Server. This plugin assumes that you manage all your videos with Plex (and none with Kodi). You might lose data already stored in the Kodi video and music databases (as this plugin directly changes them). Use at your own risk! Use at your own risk From 142c84b5011502907ae7138530696d973a6e79cc Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 7 Mar 2021 17:16:01 +0100 Subject: [PATCH 5/7] Beta version bump 3.0.14 for Kodi Matrix --- addon.xml | 14 ++++++++++++-- changelog.txt | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index dc47e6a3..3ca45e7e 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -84,7 +84,13 @@ Natūralioji „Plex“ integracija į „Kodi“ Prijunkite „Kodi“ prie „Plex Medija Serverio“. Šiame papildinyje daroma prielaida, kad valdote visus savo vaizdo įrašus naudodami „Plex“ (ir nė vieno su „Kodi“). Galite prarasti jau saugomus „Kodi“ vaizdo įrašų ir muzikos duomenų bazių duomenis (kadangi šis papildinys juos tiesiogiai pakeičia). Naudokite savo pačių rizika! Naudokite savo pačių rizika - version 3.0.13: + version 3.0.14 (beta only): +- Quickly sync recently watched items before synching the playstates of the entire Plex library +- Fix TypeError: function missing required argument 'message' +- Fix PlexKodiConnect Kodi add-on icon and fanart not showing +- Improve logging for websocket JSON loads + +version 3.0.13: - Fix UnboundLocalError: local variable 'user' referenced before assignment version 3.0.12: @@ -137,6 +143,10 @@ version 3.0.1: version 3.0.0: - Major upgrade from Python 2 to Python 3, allowing use of Kodi 19 Matrix +version 2.12.18 (beta only): +- Quickly sync recently watched items before synching the playstates of the entire Plex library +- Improve logging for websocket JSON loads + version 2.12.17 (beta only): - Sync name and user rating of a TV show season to Kodi - Fix rare TypeError: expected string or buffer on playback start diff --git a/changelog.txt b/changelog.txt index bea5b3af..e1b47e43 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +version 3.0.14 (beta only): +- Quickly sync recently watched items before synching the playstates of the entire Plex library +- Fix TypeError: function missing required argument 'message' +- Fix PlexKodiConnect Kodi add-on icon and fanart not showing +- Improve logging for websocket JSON loads + version 3.0.13: - Fix UnboundLocalError: local variable 'user' referenced before assignment @@ -51,6 +57,10 @@ version 3.0.1: version 3.0.0: - Major upgrade from Python 2 to Python 3, allowing use of Kodi 19 Matrix +version 2.12.18 (beta only): +- Quickly sync recently watched items before synching the playstates of the entire Plex library +- Improve logging for websocket JSON loads + version 2.12.17 (beta only): - Sync name and user rating of a TV show season to Kodi - Fix rare TypeError: expected string or buffer on playback start From c7ff3f573aae81db3ca79c67cd5bc791c0357f79 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Mar 2021 12:55:51 +0100 Subject: [PATCH 6/7] Rename skip intro skin file --- resources/lib/skip_plex_intro.py | 2 +- .../1080i/{skip_intro.xml => script-plex-skip_intro.xml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename resources/skins/default/1080i/{skip_intro.xml => script-plex-skip_intro.xml} (100%) diff --git a/resources/lib/skip_plex_intro.py b/resources/lib/skip_plex_intro.py index 74e1031f..b3590cab 100644 --- a/resources/lib/skip_plex_intro.py +++ b/resources/lib/skip_plex_intro.py @@ -15,7 +15,7 @@ def skip_intro(intros): if start <= progress < end: in_intro = True if in_intro and app.APP.skip_intro_dialog is None: - app.APP.skip_intro_dialog = SkipIntroDialog('skip_intro.xml', + app.APP.skip_intro_dialog = SkipIntroDialog('script-plex-skip_intro.xml', v.ADDON_PATH, 'default', '1080i', diff --git a/resources/skins/default/1080i/skip_intro.xml b/resources/skins/default/1080i/script-plex-skip_intro.xml similarity index 100% rename from resources/skins/default/1080i/skip_intro.xml rename to resources/skins/default/1080i/script-plex-skip_intro.xml From 5780f1b1a1601c705fefea1dad10d637446afc72 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Mar 2021 14:00:54 +0100 Subject: [PATCH 7/7] Stable and beta version bump 3.0.15 --- addon.xml | 8 ++++++-- changelog.txt | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index 1a63515c..3d36cf59 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -88,7 +88,11 @@ Natūralioji „Plex“ integracija į „Kodi“ Prijunkite „Kodi“ prie „Plex Medija Serverio“. Šiame papildinyje daroma prielaida, kad valdote visus savo vaizdo įrašus naudodami „Plex“ (ir nė vieno su „Kodi“). Galite prarasti jau saugomus „Kodi“ vaizdo įrašų ir muzikos duomenų bazių duomenis (kadangi šis papildinys juos tiesiogiai pakeičia). Naudokite savo pačių rizika! Naudokite savo pačių rizika - version 3.0.14 (beta only): + version 3.0.15: +- 3.0.14 for everyone +- Rename skip intro skin file + +version 3.0.14 (beta only): - Quickly sync recently watched items before synching the playstates of the entire Plex library - Fix TypeError: function missing required argument 'message' - Fix PlexKodiConnect Kodi add-on icon and fanart not showing diff --git a/changelog.txt b/changelog.txt index e1b47e43..ca7f91a3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +version 3.0.15: +- 3.0.14 for everyone +- Rename skip intro skin file + version 3.0.14 (beta only): - Quickly sync recently watched items before synching the playstates of the entire Plex library - Fix TypeError: function missing required argument 'message'