From 8e1b3444ac94632b3b86498defe0bde846b34b65 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 6 Oct 2018 14:40:14 +0200 Subject: [PATCH 1/4] Rewire Kodi library refreshs --- resources/lib/librarysync.py | 44 +++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 8209b0ca..b068d30a 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -39,6 +39,25 @@ LOG = getLogger('PLEX.librarysync') ############################################################################### +def update_library(video=True, music=True): + """ + Updates the Kodi library and thus refreshes the Kodi views and widgets + """ + if xbmc.getCondVisibility('Container.Content(musicvideos)') or \ + xbmc.getCondVisibility('Window.IsMedia'): + # Prevent cursor from moving + LOG.debug("Refreshing container") + xbmc.executebuiltin('Container.Refresh') + else: + # Update widgets + if video: + LOG.debug("Doing Kodi Video Lib update") + xbmc.executebuiltin('UpdateLibrary(video)') + if music: + LOG.debug("Doing Kodi Music Lib update") + xbmc.executebuiltin('UpdateLibrary(music)') + + @utils.thread_methods(add_suspends=['SUSPEND_LIBRARY_THREAD', 'STOP_SYNC']) class LibrarySync(Thread): """ @@ -58,8 +77,8 @@ class LibrarySync(Thread): # Need to be set accordingly later self.compare = None self.new_items_only = None - self.update_kodi_video_library = None - self.update_kodi_music_library = None + self.update_kodi_video_library = False + self.update_kodi_music_library = False self.nodes = {} self.playlists = {} self.sorted_views = [] @@ -288,9 +307,7 @@ class LibrarySync(Thread): return False # Let kodi update the views in any case, since we're doing a full sync - xbmc.executebuiltin('UpdateLibrary(video)') - if state.ENABLE_MUSIC: - xbmc.executebuiltin('UpdateLibrary(music)') + update_library(video=True, music=state.ENABLE_MUSIC) if utils.window('plex_scancrashed') == 'true': # Show warning if itemtypes.py crashed at some point @@ -1081,8 +1098,6 @@ class LibrarySync(Thread): 6: 'analyzing', 9: 'deleted' """ - self.update_kodi_video_library = False - self.update_kodi_music_library = False now = utils.unix_timestamp() delete_list = [] for i, item in enumerate(self.items_to_process): @@ -1119,12 +1134,11 @@ class LibrarySync(Thread): self.items_to_process = self.multi_delete(self.items_to_process, delete_list) # Let Kodi know of the change - if self.update_kodi_video_library is True: - LOG.info("Doing Kodi Video Lib update") - xbmc.executebuiltin('UpdateLibrary(video)') - if self.update_kodi_music_library is True: - LOG.info("Doing Kodi Music Lib update") - xbmc.executebuiltin('UpdateLibrary(music)') + if self.update_kodi_video_library or self.update_kodi_music_library: + update_library(video=self.update_kodi_video_library, + music=self.update_kodi_music_library) + self.update_kodi_video_library = False + self.update_kodi_music_library = False def process_newitems(self, item): xml = PF.GetPlexMetadata(item['ratingKey']) @@ -1378,6 +1392,10 @@ class LibrarySync(Thread): utils.unix_date_to_kodi( utils.unix_timestamp()), plex_type) + if plex_type in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_EPISODE): + update_library(video=True, music=False) + elif plex_type == v.PLEX_TYPE_SONG: + update_library(video=False, music=True) def sync_fanart(self, missing_only=True, refresh=False): """ From ab81c88b8f4a2530ba7ba0e7548fc7c2b8c7ae6e Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 6 Oct 2018 14:45:01 +0200 Subject: [PATCH 2/4] Fix flickering Kodi screen --- resources/lib/librarysync.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index b068d30a..34d8c463 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1392,10 +1392,6 @@ class LibrarySync(Thread): utils.unix_date_to_kodi( utils.unix_timestamp()), plex_type) - if plex_type in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_EPISODE): - update_library(video=True, music=False) - elif plex_type == v.PLEX_TYPE_SONG: - update_library(video=False, music=True) def sync_fanart(self, missing_only=True, refresh=False): """ From 8d9d135595f040c191e24aa0ead17a71dbc255f1 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 6 Oct 2018 15:47:41 +0200 Subject: [PATCH 3/4] Wipe Kodi database on first PKC run - Fixes #543 --- resources/lib/initialsetup.py | 4 ++++ resources/lib/kodidb_functions.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index a25f56ea..0c048a60 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -637,6 +637,10 @@ class InitialSetup(object): # dialog.ok(heading=utils.lang(29999), line1=utils.lang(39717)) # Make sure that we only ask these questions upon first installation utils.settings('InstallQuestionsAnswered', value='true') + + # New installation - make sure we start with a clean slate + from . import kodidb_functions + kodidb_functions.wipe_kodi_dbs() if goto_settings is False: # Open Settings page now? You will need to restart! diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index 7db833ab..1a9c9727 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -1253,3 +1253,30 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None): except TypeError: LOG.debug('No kodi video db element found for path %s', path) return kodi_id, kodi_type + + +def wipe_kodi_dbs(): + """ + Completely resets the Kodi databases 'video', 'texture' and 'music' (if + music sync is enabled) + """ + LOG.warn('Wiping Kodi databases!') + query = "SELECT name FROM sqlite_master WHERE type = 'table'" + kinds = ['video', 'texture'] + if state.ENABLE_MUSIC: + LOG.info('Also deleting music database') + kinds.append('music') + for db in kinds: + with GetKodiDB(db) as kodi_db: + kodi_db.cursor.execute(query) + tables = kodi_db.cursor.fetchall() + tables = [i[0] for i in tables] + if 'version' in tables: + tables.remove('version') + for table in tables: + delete_query = 'DELETE FROM %s' % table + kodi_db.cursor.execute(delete_query) + import xbmc + xbmc.executebuiltin('UpdateLibrary(video)') + if state.ENABLE_MUSIC: + xbmc.executebuiltin('UpdateLibrary(music)') From b3f222f1175bb8545f3abc4497220576f3830249 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 6 Oct 2018 15:51:10 +0200 Subject: [PATCH 4/4] Beta version bump 2.4.5 --- README.md | 2 +- addon.xml | 9 +++++++-- changelog.txt | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61b42744..7cda9e9e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![stable version](https://img.shields.io/badge/stable_version-2.4.3-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) -[![beta version](https://img.shields.io/badge/beta_version-2.4.4-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) +[![beta version](https://img.shields.io/badge/beta_version-2.4.5-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) [![Installation](https://img.shields.io/badge/wiki-installation-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/Installation) [![FAQ](https://img.shields.io/badge/wiki-FAQ-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/faq) diff --git a/addon.xml b/addon.xml index 1c26c5c1..f6874498 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -74,7 +74,12 @@ Нативна інтеграція Plex в Kodi Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик! Використовуйте на свій ризик - version 2.4.4 (beta only): + version 2.4.5 (beta only): +- Fix playback not starting up at all +- Rewire Kodi library refreshs +- Wipe Kodi database on first PKC run to more reliably install PKC + +version 2.4.4 (beta only): - Fix rare case when playback would not start-up - Increase logging diff --git a/changelog.txt b/changelog.txt index bc6f6a5c..e6713460 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +version 2.4.5 (beta only): +- Fix playback not starting up at all +- Rewire Kodi library refreshs +- Wipe Kodi database on first PKC run to more reliably install PKC + version 2.4.4 (beta only): - Fix rare case when playback would not start-up - Increase logging