This repository has been archived on 2021-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/home/.config/mpv/scripts/now_playing.lua

34 lines
984 B
Lua
Raw Normal View History

2020-05-01 01:51:42 +02:00
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