diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 9168a162..0067c8ba 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -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') diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 391fe481..555cb85a 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -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.