From 9eefa4ee4a135080e19fe1271de497243358a206 Mon Sep 17 00:00:00 2001 From: Svetlin Ankov Date: Mon, 9 Apr 2018 22:13:05 +0300 Subject: [PATCH] delete_file: fix for files not deleted on end of playlist Currently, the selected files are deleted only when mpv is exited via the quit command. If, however, the quit reason is eof of the last file in the playlist, delete_file would not delete any files. To fix this use the correct event, i.e. shutdown, instead of end-file. See: https://github.com/mpv-player/mpv/blob/master/DOCS/man/lua.rst#list-of-events --- delete_file.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/delete_file.lua b/delete_file.lua index fab11ab..ca78398 100644 --- a/delete_file.lua +++ b/delete_file.lua @@ -29,14 +29,12 @@ function mark_delete() end end -function delete(e) - if e.reason == "quit" then - for i, v in pairs(del_list) do - print("deleting: "..v) - os.remove(v) - end +function delete() + for i, v in pairs(del_list) do + print("deleting: "..v) + os.remove(v) end end mp.add_key_binding("ctrl+DEL", "delete_file", mark_delete) -mp.register_event("end-file", delete) \ No newline at end of file +mp.register_event("shutdown", delete)