Skip to content

Instantly share code, notes, and snippets.

@xMajedz
Forked from garoto/mpvhistory.lua
Last active November 12, 2018 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xMajedz/fd9f58a6f16da32fbb6ce7c2751f6986 to your computer and use it in GitHub Desktop.
Save xMajedz/fd9f58a6f16da32fbb6ce7c2751f6986 to your computer and use it in GitHub Desktop.
Simple media logger Lua script for mpv
-- Not my code: originally from https://redd.it/3t6s7k (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!
-- Changed HISTFILE Path and Name
local HISTFILE = (os.getenv('APPDATA') or os.getenv('HOME')..'/.mpv')..'/history';
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 = io.open(HISTFILE, 'a+');
logfile:write(('[%s] %s %s\n'):format(os.date('%d/%b/%y %X'), mp.get_property('path'), title));
logfile:close();
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment