From 4ed17f1a5b57d7b114a9a6f3c2a086c03885c80f Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 7 Apr 2019 15:00:14 +0200 Subject: [PATCH] Fix widgets not updating --- resources/lib/kodi_db/video.py | 8 ++++---- resources/lib/kodimonitor.py | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/resources/lib/kodi_db/video.py b/resources/lib/kodi_db/video.py index 3e794d12..2a52c34b 100644 --- a/resources/lib/kodi_db/video.py +++ b/resources/lib/kodi_db/video.py @@ -174,16 +174,16 @@ class KodiVideoDB(common.KodiDBBase): def obsolete_file_ids(self): """ Returns a generator for idFile of all Kodi file ids that do not have a - dateAdded set (dateAdded NULL) and the filename start with - 'plugin://plugin.video.plexkodiconnect' - These entries should be deleted as they're created falsely by Kodi. + dateAdded set (dateAdded NULL) and the associated path entry has + a field noUpdate of NULL as well as dateAdded of NULL """ return (x[0] for x in self.cursor.execute(""" SELECT files.idFile FROM files LEFT JOIN path ON path.idPath = files.idPath WHERE files.dateAdded IS NULL - AND path.strPath LIKE \'%plex.direct%\' + AND path.noUpdate IS NULL + AND path.dateAdded IS NULL """)) def show_id_from_path(self, path): diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 67b6afca..2202e1d3 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -435,7 +435,7 @@ def _playback_cleanup(ended=False): '{server}/video/:/transcode/universal/stop', parameters={'session': v.PKC_MACHINE_IDENTIFIER}) if status['plex_type'] in v.PLEX_VIDEOTYPES: - # Bookmarks might not be pickup up correctly, so let's do them + # Bookmarks are not be pickup up correctly, so let's do them # manually. Applies to addon paths, but direct paths might have # started playback via PMS _record_playstate(status, ended) @@ -503,13 +503,23 @@ def _record_playstate(status, ended): totaltime, playcount, last_played) + # We might need to reconsider cleaning the file/path table in the future + # _clean_file_table() + # Update the current view to show e.g. an up-to-date progress bar and use + # the latest resume point info + if xbmc.getCondVisibility('Container.Content(musicvideos)'): + # Prevent cursor from moving + xbmc.executebuiltin('Container.Refresh') + else: + # Update widgets + xbmc.executebuiltin('UpdateLibrary(video)') + if xbmc.getCondVisibility('Window.IsMedia'): + xbmc.executebuiltin('Container.Refresh') # Hack to force "in progress" widget to appear if it wasn't visible before if (app.APP.force_reload_skin and xbmc.getCondVisibility('Window.IsVisible(Home.xml)')): LOG.debug('Refreshing skin to update widgets') xbmc.executebuiltin('ReloadSkin()') - task = backgroundthread.FunctionAsTask(_clean_file_table, None) - backgroundthread.BGThreader.addTasksToFront([task]) def _clean_file_table(): @@ -520,7 +530,7 @@ def _clean_file_table(): This function tries for at most 5 seconds to clean the file table. """ LOG.debug('Start cleaning Kodi files table') - app.APP.monitor.waitForAbort(1) + # app.APP.monitor.waitForAbort(1) try: with kodi_db.KodiVideoDB() as kodidb: file_ids = list(kodidb.obsolete_file_ids())