Direct paths: correctly clean up after context menu play
This commit is contained in:
parent
c48ef5012f
commit
4e85b65318
3 changed files with 15 additions and 1 deletions
|
@ -204,6 +204,14 @@ class KodiDBMethods(object):
|
|||
self.cursor.execute(query, (file_id, path_id, filename, date_added))
|
||||
return file_id
|
||||
|
||||
def clean_file_table(self):
|
||||
"""
|
||||
Hack: using Direct Paths, Kodi adds all addon paths to the files table
|
||||
but without a dateAdded entry. This method cleans up all file entries
|
||||
without a dateAdded entry - to be called after playback has ended.
|
||||
"""
|
||||
self.cursor.execute('DELETE FROM files where dateAdded IS NULL')
|
||||
|
||||
def remove_file(self, file_id):
|
||||
"""
|
||||
Removes the entry for file_id from the files table. Will also delete
|
||||
|
|
|
@ -164,7 +164,10 @@ def _ensure_resolve(abort=False):
|
|||
will be destroyed.
|
||||
"""
|
||||
if RESOLVE:
|
||||
state.PKC_CAUSED_STOP = True
|
||||
LOG.debug('Passing dummy path to Kodi')
|
||||
if not state.CONTEXT_MENU_PLAY:
|
||||
# Because playback won't start with context menu play
|
||||
state.PKC_CAUSED_STOP = True
|
||||
result = Playback_Successful()
|
||||
result.listitem = PKC_ListItem(path='PKC_Dummy_Path_Which_Fails')
|
||||
pickle_me(result)
|
||||
|
|
|
@ -53,6 +53,9 @@ def playback_cleanup():
|
|||
|
||||
|
||||
def _record_playstate(status):
|
||||
with kodidb.GetKodiDB('video') as kodi_db:
|
||||
# Hack - remove any obsolete file entries Kodi made
|
||||
kodi_db.clean_file_table()
|
||||
if not status['plex_id']:
|
||||
LOG.debug('No Plex id found to record playstate for status %s', status)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue