Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple media logger Lua script for mpv
-- Not my code: originally from (author deleted; failed to ask for permission).
-- Only tested on Windows. Date is set to dd/mmm/yy and time to machine-wide format.
-- Save as "mpvhistory.lua" in your mpv scripts dir. Log will be saved to mpv default config directory.
-- Make sure to leave a comment if you make any improvements/changes to the script!
local HISTFILE = (os.getenv('APPDATA') or os.getenv('HOME')..'/.config')..'/mpv/mpvhistory.log';
mp.register_event('file-loaded', function()
local title, logfile;
title = mp.get_property('media-title');
title = (title == mp.get_property('filename') and '' or ('(%s)'):format(title));
logfile =, 'a+');
logfile:write(('[%s] %s %s\n'):format('%d/%b/%y %X'), mp.get_property('path'), title));
Copy link

ipatch commented Aug 29, 2018

great script, I'd suggest using double quotes instead of single quotes IMHO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment