[download]

config/mpv/scripts/history.lua

   1 mp.register_event('file-loaded', function()
   2     local path  = mp.get_property('path');
   3     local time  = os.date('%Y-%m-%d %H:%M:%S');
   4     local title = mp.get_property('media-title');
   5 
   6     local pos_pr = mp.get_property('percent-pos')
   7     local pos_tm = os.date('!%H:%M:%S', mp.get_property('time-pos') or 0);
   8 
   9     local home = os.getenv('HOME') or os.getenv('HOMEPATH');
  10     local conf = os.getenv('APPDATA') or home..'/.config';
  11 
  12     local file = io.open(conf..'/mpv/history.log', 'a+');
  13     file:write(('[%s] "%s" %s (%d%%) - %s\n'):format(
  14         time, title, pos_tm, pos_pr, path:gsub(home, '~')
  15     ));
  16     file:close();
  17 end);