Direct paths: fix replaying item where playback was started via PMS
This commit is contained in:
parent
30abe0f2fb
commit
7a4997da7a
2 changed files with 32 additions and 9 deletions
|
@ -5,6 +5,8 @@ from logging import getLogger
|
||||||
from ntpath import dirname
|
from ntpath import dirname
|
||||||
from sqlite3 import IntegrityError
|
from sqlite3 import IntegrityError
|
||||||
|
|
||||||
|
import xbmc
|
||||||
|
|
||||||
import artwork
|
import artwork
|
||||||
from utils import kodi_sql, try_decode, unix_timestamp, unix_date_to_kodi
|
from utils import kodi_sql, try_decode, unix_timestamp, unix_date_to_kodi
|
||||||
import variables as v
|
import variables as v
|
||||||
|
@ -210,18 +212,33 @@ class KodiDBMethods(object):
|
||||||
but without a dateAdded entry. This method cleans up all file entries
|
but without a dateAdded entry. This method cleans up all file entries
|
||||||
without a dateAdded entry - to be called after playback has ended.
|
without a dateAdded entry - to be called after playback has ended.
|
||||||
"""
|
"""
|
||||||
self.cursor.execute('SELECT idFile FROM files WHERE dateAdded IS NULL')
|
query = '''
|
||||||
|
SELECT idFile FROM files
|
||||||
|
WHERE dateAdded IS NULL
|
||||||
|
AND strFilename LIKE \'plugin://plugin.video.plexkodiconnect%\'
|
||||||
|
'''
|
||||||
|
i = 0
|
||||||
|
while i < 100:
|
||||||
|
self.cursor.execute(query)
|
||||||
files = self.cursor.fetchall()
|
files = self.cursor.fetchall()
|
||||||
self.cursor.execute('DELETE FROM files where dateAdded IS NULL')
|
if files:
|
||||||
for file in files:
|
break
|
||||||
|
# Make sure Kodi recorded "false" playstate FIRST before
|
||||||
|
# cleaning it
|
||||||
|
i += 1
|
||||||
|
xbmc.sleep(100)
|
||||||
|
for item in files:
|
||||||
|
LOG.debug('Cleaning file id: %s', item[0])
|
||||||
|
self.cursor.execute('DELETE FROM files WHERE idFile = ?',
|
||||||
|
(item[0],))
|
||||||
self.cursor.execute('DELETE FROM bookmark WHERE idFile = ?',
|
self.cursor.execute('DELETE FROM bookmark WHERE idFile = ?',
|
||||||
(file[0],))
|
(item[0],))
|
||||||
self.cursor.execute('DELETE FROM settings WHERE idFile = ?',
|
self.cursor.execute('DELETE FROM settings WHERE idFile = ?',
|
||||||
(file[0],))
|
(item[0],))
|
||||||
self.cursor.execute('DELETE FROM streamdetails WHERE idFile = ?',
|
self.cursor.execute('DELETE FROM streamdetails WHERE idFile = ?',
|
||||||
(file[0],))
|
(item[0],))
|
||||||
self.cursor.execute('DELETE FROM stacktimes WHERE idFile = ?',
|
self.cursor.execute('DELETE FROM stacktimes WHERE idFile = ?',
|
||||||
(file[0],))
|
(item[0],))
|
||||||
|
|
||||||
def show_id_from_path(self, path):
|
def show_id_from_path(self, path):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -28,7 +28,8 @@ def playback_cleanup(ended=False):
|
||||||
completely finished playing an item (because we will get and use wrong
|
completely finished playing an item (because we will get and use wrong
|
||||||
timing data otherwise)
|
timing data otherwise)
|
||||||
"""
|
"""
|
||||||
LOG.debug('playback_cleanup called')
|
LOG.debug('playback_cleanup called. Active players: %s',
|
||||||
|
state.ACTIVE_PLAYERS)
|
||||||
# We might have saved a transient token from a user flinging media via
|
# We might have saved a transient token from a user flinging media via
|
||||||
# Companion (if we could not use the playqueue to store the token)
|
# Companion (if we could not use the playqueue to store the token)
|
||||||
state.PLEX_TRANSIENT_TOKEN = None
|
state.PLEX_TRANSIENT_TOKEN = None
|
||||||
|
@ -106,6 +107,11 @@ def _record_playstate(status, ended):
|
||||||
xbmc.getCondVisibility('Window.IsVisible(Home.xml)')):
|
xbmc.getCondVisibility('Window.IsVisible(Home.xml)')):
|
||||||
LOG.debug('Refreshing skin to update widgets')
|
LOG.debug('Refreshing skin to update widgets')
|
||||||
xbmc.executebuiltin('ReloadSkin()')
|
xbmc.executebuiltin('ReloadSkin()')
|
||||||
|
if (state.DIRECT_PATHS and
|
||||||
|
status['playmethod'] in ('DirectStream', 'Transcode')):
|
||||||
|
LOG.debug('Start cleaning Kodi files table')
|
||||||
|
with kodidb.GetKodiDB('video') as kodi_db:
|
||||||
|
kodi_db.clean_file_table()
|
||||||
|
|
||||||
|
|
||||||
class PKC_Player(xbmc.Player):
|
class PKC_Player(xbmc.Player):
|
||||||
|
|
Loading…
Reference in a new issue