mpv: Add now_playing script

This commit is contained in:
Simon Bruder 2020-05-01 01:51:42 +02:00
parent 4a5b869397
commit 793467295f
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F

View file

@ -0,0 +1,33 @@
require 'mp.options'
function handle_file_load ()
if mp.get_property("metadata/by-key/artist") == nil and mp.get_property("metadata/by-key/title") == nil then
-- media-title is filename if no title is set
if mp.get_property("media-title") ~= mp.get_property("filename") then
info = mp.get_property("media-title")
else
info = mp.get_property("filename/no-ext")
end
else
info = mp.get_property("metadata/by-key/artist") .. " " .. mp.get_property("metadata/by-key/title")
end
-- check for youtube-dl
if mp.get_property("stream-open-filename") ~= mp.get_property("path") then
info = info .. "\n(" .. mp.get_property("path") .. ")"
end
file = io.open(options.write, "w")
io.output(file)
io.write(info .. "\n")
io.close(file)
end
options = {
write = "",
}
read_options(options)
if options.write ~= "" then
mp.register_event("file-loaded", handle_file_load)
end