Delete temporary subtitles on playback stop

This commit is contained in:
croneter 2019-10-05 16:50:04 +02:00
parent af23a4aabd
commit 1fa1035a43
2 changed files with 14 additions and 0 deletions

View file

@ -450,6 +450,7 @@ def _playback_cleanup(ended=False):
# As all playback has halted, reset the players that have been active
app.PLAYSTATE.active_players = set()
app.PLAYSTATE.item = None
utils.delete_temporary_subtitles()
LOG.info('Finished PKC playback cleanup')

View file

@ -512,6 +512,19 @@ def escape_html(string):
return string
def delete_temporary_subtitles():
"""
Permanently deletes all temporary subtitle files
"""
for root, _, files in path_ops.walk(v.EXTERNAL_SUBTITLE_TEMP_PATH):
for file in files:
try:
path_ops.remove(path_ops.path.join(root, file))
except (OSError, IOError) as err:
LOG.error('Could not delete temporary subtitle: %s, %s: %s',
root, file, err)
def kodi_sql(media_type=None):
"""
Open a connection to the Kodi database.