Fix widgets not updating

This commit is contained in:
croneter 2019-04-07 15:00:14 +02:00
parent 484b03482e
commit 4ed17f1a5b
2 changed files with 18 additions and 8 deletions

View file

@ -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):

View file

@ -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())