mpv: Add now_playing script
This commit is contained in:
parent
4a5b869397
commit
793467295f
33
home/.config/mpv/scripts/now_playing.lua
Normal file
33
home/.config/mpv/scripts/now_playing.lua
Normal 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
|
Reference in a new issue