Merge pull request #1012 from croneter/delete-subs

Delete temporary subtitles on playback stop
This commit is contained in:
croneter 2019-10-05 17:01:10 +02:00 committed by GitHub
commit feb73b7e47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 # As all playback has halted, reset the players that have been active
app.PLAYSTATE.active_players = set() app.PLAYSTATE.active_players = set()
app.PLAYSTATE.item = None app.PLAYSTATE.item = None
utils.delete_temporary_subtitles()
LOG.info('Finished PKC playback cleanup') LOG.info('Finished PKC playback cleanup')

View file

@ -512,6 +512,19 @@ def escape_html(string):
return 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): def kodi_sql(media_type=None):
""" """
Open a connection to the Kodi database. Open a connection to the Kodi database.