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 Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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