mpv: printout marked files using the "M" key similar to sxiv

This commit is contained in:
Alexander Bocken 2024-09-20 10:31:32 +02:00
parent a73c95b3a6
commit 76e72f4d46
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -0,0 +1,30 @@
-- mpv script to mark videos
local utils = require 'mp.utils'
local marked_videos = {}
local marked_file = "marked"
function toggle_mark()
local path = mp.get_property("path")
if marked_videos[path] then
marked_videos[path] = nil
mp.osd_message("Unmarked: " .. path)
else
marked_videos[path] = true
mp.osd_message("Marked: " .. path)
end
end
function save_marks()
-- Do not write anything if "marked_videos" is empty
if next(marked_videos) == nil then
return
end
local file = io.open(marked_file, "a")
for path, _ in pairs(marked_videos) do
file:write(path .. "\n")
end
file:close()
end
mp.add_key_binding("M", "toggle_mark", toggle_mark)
mp.register_event("shutdown", save_marks)