config/mpv/scripts/history.lua

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