Skip to content

Instantly share code, notes, and snippets.

@TheAMM
Created June 27, 2023 18:51
Show Gist options
  • Save TheAMM/1e7e7da233cec68c9e441133df3ddd47 to your computer and use it in GitHub Desktop.
Save TheAMM/1e7e7da233cec68c9e441133df3ddd47 to your computer and use it in GitHub Desktop.
Script to dump mpv properties with
local utils = require 'mp.utils'
local msg = require 'mp.msg'
--[[
Simple script to dump all available properties, optionally to a file.
Open console and type:
script-message dump-properties
Append a filename to write to:
script-message dump-properties props.txt
Example input.conf bind:
ctrl+d script-message dump-properties /tmp/all_properties.txt
]]--
function dump_properties(output_path)
local properties = mp.get_property_native("property-list")
-- Optionally, write to a file
local output_file = nil
if output_path then
output_file = io.open(output_path, 'w')
if not output_file then
msg.error(("Unable to open file %q for dumping properties"):format(output_path))
return
end
msg.info(("Writing %d properties to file %q"):format(#properties, output_path))
else
msg.info(("Dumping %d properties"):format(#properties, output_path))
end
for _, name in pairs(properties) do
local value = utils.to_string(mp.get_property_native(name))
if output_file then
output_file:write(('%s\t%s\n'):format(name, value))
else
msg.info(("%s\t%s"):format(name, value))
end
end
if output_file then
output_file:close()
end
end
mp.register_script_message('dump-properties', dump_properties)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment